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