1

I want OnitemClickListener for a listview but it doesn't work for me.it give Logcat error that.

Your content must have a listview whose id attribute is R.id.list

and my application do not launches . I uses sqlite in my project to store a number and display it in a listview.

<ListView
    android:id="@+id/list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:choiceMode="multipleChoice" />

this code is for click ..

 ListView listView1 = (ListView) findViewById(R.id.list);

    listView1.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
            // TODO Auto-generated method stub
            Toast.makeText(getApplicationContext(), "item clicked: ",Toast.LENGTH_SHORT).show();
        }
    });
Charuක
  • 12,953
  • 5
  • 50
  • 88
Abdus Salam
  • 55
  • 1
  • 11
  • Its already been answered many times here in stackOverflow. Have you done searching http://stackoverflow.com/questions/11050817/your-content-must-have-a-listview-whose-id-attribute-is-android-r-id-list – Androyds Feb 06 '13 at 07:25
  • @Androyds thanks for response. yes i have searched. now ** ListView listView1 = (ListView) findViewById(R.id.);** doesnot show the list id. for 'android:id="@+id/android:list' – Abdus Salam Feb 06 '13 at 07:46

1 Answers1

1

use @+id/android:list it might work then

Rajitha Siriwardena
  • 2,749
  • 1
  • 18
  • 22