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. Recyclerview OnItem单击监听器不工作
- 2. fire OnItem点击按钮时点击listview
- 3. Onitem长按不工作列表视图
- 4. 点击不工作
- 5. ng点击工作不点击
- 6. jQuery的点击(只点击)不工作
- 7. 第一次点击不工作在jquery
- 8. 点击下一页casperjs不工作
- 9. 点击在GridView第一项工作不
- 10. 我想中心一个div在另一个div但不工作?
- 11. Onitem单击列表工具不能在列表视图
- 12. AJAX不工作的第一次点击,需要点击两次
- 13. 按钮上点击不工作第一次点击
- 14. JQuery的点击不工作
- 15. 。对(“点击”,funcion不工作
- 16. 我点击不工作
- 17. 检测点击不工作
- 18. 如何不点击工作?
- 19. 输入点击不工作
- 20. NG点击不工作
- 21. 点击后jQuery不工作
- 22. jQuery的点击()不工作
- 23. onItemClick点击不工作
- 24. jquery锚点击不工作
- 25. $(“#提交”)点击不工作:/
- 26. jQuery的。点击()不工作
- 27. 的addEventListener点击不工作
- 28. angularjs NG-点击不工作
- 29. 触发点击不工作
- 30. JQuery点击+这不工作
什么是 '不工作' 是什么意思? – StarPinkER 2013-03-02 07:17:35
而不是空使用上下文或activityname.this – 2013-03-02 07:17:57