setOnItemClickListener not getting called

前端 未结 3 945
盖世英雄少女心
盖世英雄少女心 2020-12-07 05:54

I have this in the onCreate method as follows:

    ListView lv = (ListView)findViewById(android.R.id.list);
   adapter = new ModuleAdapter(this);
   lv.setAd         


        
相关标签:
3条回答
  • 2020-12-07 06:42

    Do you set FocusableInTouchMode to be true in your layout? If so then onItemClick will not be called.

    0 讨论(0)
  • 2020-12-07 06:52

    Try this changes in the xxx_row.xml

    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:enabled="false">
    </TextView>
    

    At least for me it worked when i changed the width and enabled attributes.

    0 讨论(0)
  • 2020-12-07 06:57

    ListView lv = (ListView)findViewById(android.R.id.list); - it's if you trying to get android System resources, but you want listview wich you describe on xml layout.

    Let's say it's look like:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
    
        <ListView
            android:id="@+id/listView1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >
        </ListView>
    
    </LinearLayout>
    

    so you need change your code to

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

    Some explain: android.R - it's default resources of Android OS - llike buttons,images, listview items layouts and etc. R. - it' your project resoures full path likes [your package path].R for example: com.example.R

    0 讨论(0)
提交回复
热议问题