我正在努力做到这一点,因此当您单击第 2 行或第 4 行时,它运行的方法与其余列表项不同。其余的去一个网站,但我希望第 4 行打开电子邮件,第 2 行打开导航器。但是当我单击第 4 行时,它会打开浏览器(即通过 Intent),然后在我退出后打开电子邮件。为什么?--另外,导航器强制关闭,但我认为它的原因是模拟器没有安装导航器:/有什么建议吗?谢谢!
getListView().setOnItemClickListener(new OnItemClickListener() {final String[] links =getResources().getStringArray(com.BandCustomListView.R.array.ItemLinks); @Override public void onItemClick(AdapterView parent, View view, int position, long 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);
}
}
});