0
我的代碼讀取一個包含字符串的.txt文件,並將它們顯示在我的列表視圖中。但是,如何讀取另一個包含指向圖像的鏈接的.txt文件,然後將這些圖像作爲縮略圖加載到每個列表項中?如何添加縮略圖列表項?
listView1 = (ListView) findViewById(R.id.listView1);
try {
String filePath = Environment.getExternalStorageDirectory()
.getAbsolutePath() + "/my_market_apps_list.txt";
BufferedReader br = new BufferedReader(new InputStreamReader(
new FileInputStream(filePath), "Cp1252"), 100);
String line;
final ArrayList<String> lines = new ArrayList<String>();
while ((line = br.readLine()) != null) {
lines.add(line);
}
br.close();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, lines);
listView1.setAdapter(adapter);
listView1.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
startActivity(new Intent(
Intent.ACTION_VIEW,
Uri.parse("http://play.google.com/store/apps/details?id="
+ lines.get(position))));
}
});
} catch (Exception e) {
e.printStackTrace();
}