0
我試圖做到這一點,當你點擊第2或第4行時,它會運行與列表項不同的其他方法。其餘的去一個網站,但我想第4行打開電子郵件,第2行打開導航。但是當我點擊第4行時,它會打開瀏覽器(即通過意圖),然後在我返回後打開電子郵件。爲什麼? - 另外,導航部隊關閉,但我認爲它的原因模擬器沒有安裝導航器:/任何建議?謝謝! 。ListView onItemClick按位置
getListView()setOnItemClickListener(新OnItemClickListener(){最終字符串[]鏈接= getResources()getStringArray(com.BandCustomListView.R.array.ItemLinks); @Override 公共無效onItemClick(適配器視圖父,查看看來,INT位置, 長ID){
String positions = links[position];
if (position == 4){
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject");
;
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
}
if (position == 2){
Intent i = new Intent(Intent.ACTION_VIEW,
Uri.parse("google.navigation:q=127+Southbridge+Street+Auburn+Massachusetts"));
startActivity(i);
}
if (position != (2 | 4)) {
Intent SendToWebPageView = new Intent(getApplicationContext(), WebPageView.class);
SendToWebPageView.setData(Uri.parse(positions));
startActivity(SendToWebPageView);
}
}
});
謝謝!有效 :) – Bob