我试图使它,所以当你点击第2行或第4行它运行一个不同的方法比其余的列表项。剩下的去一个网站,但我想让第4行打开电子邮件,第2行打开导航器。但是当我点击第4行时,它打开浏览器(即传递意图),然后在我退出后打开电子邮件。为什么?-还有,导航器强制关闭,但我认为这是模拟器没有安装导航器的原因:/任何建议?谢谢!
getListView()。setOnItemClickListener(new OnItemClickListener() {final String[] links =getResources().getStringArray(com. bandcustomlistview . r.a rarray . itemlinks);@OverrideonItemClick(adapterviewparent, View View, int position)长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[]{"Mtarpey@worcester.edu"});
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);
}
}
});
我想你可能想改变这个LOC
if (position != (2 | 4))
if(position != 2 &&位置!= 4)