2013-03-02 71 views
0
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); 
+0

什么是 '不工作' 是什么意思? – StarPinkER 2013-03-02 07:17:35

+0

而不是空使用上下文或activityname.this – 2013-03-02 07:17:57

回答

1

试试这个,而不是空的使用getapplicationcontext()..

0
usersList.setOnItemClickListener(new AdapterView.OnItemClickListener() { 

在这里,你已经使用的适配器观,这是父类的自定义适配器的视图。这就是为什么它不起作用。相反,您应该使用自定义适配器视图。

此处的getView()函数可帮助您将父视图视图转换为自定义视图。

所以您使用的两个选项,

usersList.setOnItemClickListener(new CustomAdapterView.OnItemClickListener() { 

usersList.setOnItemClickListener(new OnItemClickListener() { 
3

改变这一行。

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活动。

0

为什么传递null而不是上下文?
添加上下文的意图

Intent i = new Intent(yourclassname.this, Ldetail.class); 
0
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); 
+0

我试过Intent i = new Intent(this,Ldetail.class); Intent i = new Intent(getBaseContext(),Ldetail.class); 但我虽然得到运行时错误 – 2013-03-02 07:30:48

+0

告诉我你的错误第一 – duggu 2013-03-02 07:32:47

+0

我如何发送日志猫的屏幕截图? – 2013-03-02 07:35:16