onListItemClick и CheckedTextView не переделывают - PullRequest
0 голосов
/ 15 февраля 2010

Я получил ListActivity, каждый элемент имеет 2 изображения textviews и CheckedTextView. Я пытаюсь реализовать простой мультишуазлист ... У меня две проблемы: 1.

     @Override
      protected void onListItemClick(android.widget.ListView l, View v,
        int position, long id)
             {
                ...
              }

не отвечает вообще, я пробовал это с отладчиком, и когда я нажимаю на любой элемент списка, он не останавливается там. и я пробовал все виды вещей (например, focusable:false)

два :. Я все равно не могу переключить CheckedTextView.

вот мой xml:

            <?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="100sp"
android:focusable="false" android:focusableInTouchMode="false">
android:padding="6dip">

<ImageView android:layout_width="wrap_content"
    android:layout_height="fill_parent" android:src="@drawable/icon"
    android:id="@drawable/icon" android:layout_marginLeft="6dip"
    android:focusable="false" android:focusableInTouchMode="false">


</ImageView>


<LinearLayout android:id="@+id/LinearLayout01"
    android:orientation="vertical" android:layout_width="1sp"
    android:layout_height="fill_parent" android:layout_weight="1"
    android:focusable="false" android:focusableInTouchMode="false">

    <TextView android:id="@+id/toptext" android:layout_weight="1"
        android:gravity="center_vertical" android:text="OrderNum"
        android:singleLine="true" android:layout_height="0dp"
        android:layout_width="wrap_content" android:focusable="false"
        android:focusableInTouchMode="false">

    </TextView>



    <TextView android:id="@+id/bottomtext" android:layout_height="wrap_content"
        android:layout_width="wrap_content" android:focusable="false"
        android:focusableInTouchMode="false" android:text="TweetMsg">
    </TextView>


    <TextView android:id="@+id/twittLocation"
        android:layout_weight="1" android:text="location" android:singleLine="true"
        android:layout_width="fill_parent" android:layout_height="0dip"
        android:focusable="false" android:focusableInTouchMode="false">
    </TextView>
    <TextView android:layout_weight="1" android:id="@+id/twittLocationlink"
        android:text="locationlink" android:gravity="fill_horizontal"
        android:layout_width="fill_parent" android:layout_height="0dip"
        android:focusable="false" android:focusableInTouchMode="false">
    </TextView>





</LinearLayout>




<CheckedTextView android:id="@android:id/text1"  android:text="Delete"
    android:layout_width="wrap_content" android:layout_marginRight="2dp"
    android:layout_height="fill_parent"
    android:checkMark="?android:attr/listChoiceIndicatorMultiple"

    android:focusable="false"></CheckedTextView>



</LinearLayout>

Есть идеи, в чем проблема? спасибо.

Ответы [ 2 ]

0 голосов
/ 18 октября 2014

Попробуйте этот код:

public class Sample extends ListFragment implements OnItemClickListener{

ListView list;

list.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1,
                    int arg2, long arg3) {


            }

        });

}

Пример кода

0 голосов
/ 31 июля 2012

В вашем списке ListView android:descendantFocusability="beforeDescendants". Это может помочь.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...