2013-01-24 41 views
-2
ListView lv=(ListView) findViewById(android.R.id.list); 
     lv.setOnItemLongClickListener(new OnItemLongClickListener()//error:change to <listeners> 
{ 
      public boolean onItemLongClick(AdapterView<?> arg0, View arg1,int row, long arg3) { 

       //here is where i got the classCastException. 
       String[] tmp = (String[]) arg0.getItemAtPosition(row); 

       //tmp[0] ist the Text of the first TextView displayed by the clicked ListItem 
       Toast.makeText(ReminderListActivity.this, tmp[0].toString(), Toast.LENGTH_SHORT).show(); 

       return true; 
      } 
     }); 
+0

什么是你的问题? –

+0

在第二行,我收到一个错误,即更改为setOnClickListener,当我点击它时,我得到另一个建议来更改监听器的类型。所以请帮助。 – rajkaushal

回答

0

改变列表视图来lv.setOnItemClickListener

+0

现在我收到错误,即更改为setOnFocusListener。 – rajkaushal

0

您需要解决您的进口。
你可能导入了错误的类,现在eclipse认为你想要别的东西。

0

你应该使用下面听众:

m_listView.setOnItemClickListener(new OnItemClickListener() 
    { 
     @Override 
     public void onItemClick(AdapterView<?> p_arg0, View p_arg1, int p_arg2, long p_arg3) 
     { 
      // TODO Auto-generated method stub 
     } 
    });