Android 列表视图 OnClickListener 不工作

Android Listview OnClickListener not working

我的问题是,当我在主布局中单击列表项时,有时它会被触发,但不是所有时候。 我不知道如何解决这个问题? 请帮帮我..

我的代码是:

View v = convertView.findViewById(R.id.chat_window_single);
v.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Log.i("position",v.getTag().toString());
        SharedPreferences.Editor editor = sharedpreferences.edit();
        editor.putLong("eventId", groupEventMoList.get(Integer.parseInt(v.getTag().toString())).getEventId());
        editor.putString("eventTitle",groupEventMoList.get(Integer.parseInt(v.getTag().toString())).getText());
        editor.commit();
        Intent groupAct = new Intent(context, GroupChatActivity.class);
        startActivity(groupAct);
    }

});

我的布局文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/chat_window_single"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:orientation="vertical"
android:descendantFocusability="blocksDescendants">

<TextView
    android:id="@+id/chat_title"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="5sp"
    android:shadowDx="1"
    android:shadowDy="1"
    android:textColor="@android:color/primary_text_light"
    android:textSize="20sp" >
</TextView>

<TextView
    android:id="@+id/event_place"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="5sp"
    android:shadowDx="1"
    android:shadowDy="1"
    android:textColor="@android:color/primary_text_light"
    android:textSize="20sp" >
</TextView>

<TextView
    android:id="@+id/event_date"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="5sp"
    android:shadowDx="1"
    android:shadowDy="1"
    android:textColor="@android:color/primary_text_light"
    android:textSize="20sp" >
 </TextView>

 </LinearLayout>

我的主要布局文件:

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical" >

<ListView
    android:id="@+id/chat_list_view"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="80dp" >

</ListView>
</LinearLayout>

任何帮助将不胜感激。

您的文本视图正在从父列表视图中窃取焦点,使它们 clickablefocusable = false 也是最上面的线性布局需要 android:descendantFocusability="blocksDescendants"