lv.setAdapter(adp);
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
Cursor c = (Cursor)arg0.getItemAtPosition(arg2);
call = c.getString(0);
Intent i = new Intent(null, Ldetail.class);
i.putExtra("id",call);
startActivity(i);
回答
试试这个,而不是空的使用getapplicationcontext()..
usersList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
在这里,你已经使用的适配器观,这是父类的自定义适配器的视图。这就是为什么它不起作用。相反,您应该使用自定义适配器视图。
此处的getView()函数可帮助您将父视图视图转换为自定义视图。
所以您使用的两个选项,
usersList.setOnItemClickListener(new CustomAdapterView.OnItemClickListener() {
或
usersList.setOnItemClickListener(new OnItemClickListener() {
改变这一行。
Intent i = new Intent(null, Ldetail.class);
而不是null use context或activityname.this。您必须传递上下文或活动名称。
Intent i = new Intent(YourCurrentActivityName.this, Ldetail.class);
或者
Intent i = new Intent(getBaseContext(), Ldetail.class);
,并宣布在Android清单文件Ldetail活动。
为什么传递null而不是上下文?
添加上下文的意图
Intent i = new Intent(yourclassname.this, Ldetail.class);
Intent i = new Intent(null, Ldetail.class);
i.putExtra("id",call);
startActivity(i);
您必须通过情境或活动。
Intent i = new Intent(this, Ldetail.class);
或
Intent i = new Intent(getBaseContext(), Ldetail.class);
我试过Intent i = new Intent(this,Ldetail.class); Intent i = new Intent(getBaseContext(),Ldetail.class); 但我虽然得到运行时错误 – 2013-03-02 07:30:48
告诉我你的错误第一 – duggu 2013-03-02 07:32:47
我如何发送日志猫的屏幕截图? – 2013-03-02 07:35:16
- 1. fire OnItem点击按钮时点击listview
- 2. 点击不工作
- 3. 点击下一页casperjs不工作
- 4. 点击在GridView第一项工作不
- 5. 按钮上点击不工作第一次点击
- 6. AJAX不工作的第一次点击,需要点击两次
- 7. JQuery点击+这不工作
- 8. jQuery的。点击()不工作
- 9. 检测点击不工作
- 10. $(“#提交”)点击不工作:/
- 11. 点击后jQuery不工作
- 12. 的addEventListener点击不工作
- 13. 我点击不工作
- 14. 触发点击不工作
- 15. 点击不工作在硒
- 16. NG点击不工作
- 17. 点击时UIPageController点不工作
- 18. 不能让焦点工作像我想
- 19. Qtip它不工作的第一次点击,下次点击一切OK
- 20. jQuery:不选择不工作点击
- 21. onItem点击ListView中的项目后滚动抛出NullPointerException
- 22. 如何在SimpleCursorAdapter中实现onitem点击监听器
- 23. 重定向OnItem点击一个ListView到真正的触摸项目视图
- 24. MPMoviePlayerController不想工作
- 25. jQuery点击只能工作一次
- 26. 点击()不在轨道工作3.2.1 - 自动点击
- 27. 点击jQuery的调用不工作的按钮,点击
- 28. jQuery的点击功能不工作当点击图像
- 29. jQuery的。对( “点击”)后.off不工作( “点击”)
- 30. POST不点击函数内部工作
什么是 '不工作' 是什么意思? – StarPinkER 2013-03-02 07:17:35
而不是空使用上下文或activityname.this – 2013-03-02 07:17:57