Android: Context menu doesn't show up for ListView with members defined by LinearLayout?

Posted by RandomEngy on Stack Overflow See other posts from Stack Overflow or by RandomEngy
Published on 2010-05-23T02:44:38Z Indexed on 2010/05/23 2:50 UTC
Read the original article Hit count: 413

Filed under:
|
|

I've got a ListActivity and ListView and I've bound some data to it. The data shows up fine, and I've also registered a context menu for the view. When I display the list items as just a simple TextView, it works fine:

<TextView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/nametext"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

However when I try something a bit more complex, like show the name and a CheckBox, the menu never shows up:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView android:id="@+id/nametext"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
    <CheckBox
        android:id="@+id/namecheckbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />
</LinearLayout>

Can long-presses work on more complex elements? I'm building on 2.1.

© Stack Overflow or respective owner

Related posts about java

Related posts about android