我的代碼將包名從.txt
文件填充到ListView中,並且我希望單擊時在Google Play商店中打開每個列表項。如何獲取列表項(包名)?如何在列表視圖中獲取列表項的位置?
startActivity(new Intent(
Intent.ACTION_VIEW,
Uri.parse("http://play.google.com/store/apps/details?id="
+ "com.utorrent.client")));
我的列表視圖:
try {
String filePath = Environment.getExternalStorageDirectory()
.getAbsolutePath() + "/vers.txt";
BufferedReader br = new BufferedReader(new InputStreamReader(
new FileInputStream(filePath), "Cp1252"), 100);
String line;
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);
} catch (Exception e) {
e.printStackTrace();
}
}
也許你應該在你的'ListView' – Karakuri