0
嘿我想显示一个Web视图,如果有人点击列表中的第五项。获取列表中的位置,然后显示Web视图
这是代码:
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int position,
long id) {
if (position == 5) {
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse(href2_final
+ "=service&doc_library=ABN01&doc_number="
+ record_parsed_final
+ "&line_number=0001&func_code=WEB-FULL&service_type=MEDIA");
intent.setData(uri);
startActivity(intent);
}
}
});
我在做什么错?如果我删除IF语句,那么当我按列表中的任何项目时,它将启动Web视图。
谢谢!
多少个项目你有名单上的索引? – Jayaram 2012-04-26 21:44:21
loool这很搞笑!位置== 5绝对是第五项 – 2012-04-26 22:11:05
@SherifelKhatib:你确定吗?我只测试了它,列表中的第一个元素的'position'为零。 – Chopin 2012-04-26 23:55:55