-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;
             }
         });
4

3 回答 3

0

你需要修复你的导入。
你可能导入了错误的类,现在 eclipse 认为你想要别的东西。

于 2013-01-24T10:36:57.857 回答
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
        }
    });
于 2013-01-24T10:37:24.930 回答
0

改成lv.setOnItemClickListener

于 2013-01-24T10:30:09.930 回答