1. Check out our companion app, Forums for Android! Download from Google Play

multi select in cutom listview

Discussion in 'Application Development' started by nokachouik, Nov 17, 2010.

  1. nokachouik

    nokachouik Member
    Thread Starter
    5

    Nov 16, 2010
    7
    0
    5
    Hi everybody,

    In a first time sorry for my english -_-'
    I have a problem with my listview.
    My listview is a custom listview with one imageview and two textview.
    And i would like to know how to select some of items in my list using checkbox. I've tried to enable the CHOICE_MODE_MULTIPLE but without success.

    this is my layout
    Code (Text):
    1.  
    2. <?xml version="1.0" encoding="utf-8"?>
    3. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    4.     android:layout_width="fill_parent"
    5.     android:layout_height="?android:attr/listPreferredItemHeight"
    6.     android:padding="6dip">
    7.     <ImageView
    8.         android:id="@+id/icon"
    9.         android:layout_width="60sp"
    10.         android:layout_height="60sp"
    11.         android:layout_marginRight="6dip"
    12.         android:src="@drawable/contact_icon2"
    13.         />
    14.     <LinearLayout
    15.         android:orientation="vertical"
    16.         android:layout_width="0dip"
    17.         android:layout_weight="1"
    18.         android:layout_height="fill_parent">
    19.         <TextView
    20.             android:id="@+id/toptext"
    21.             android:layout_width="fill_parent"
    22.             android:layout_height="0dip"
    23.             android:layout_weight="1"
    24.             android:gravity="center_vertical"
    25.             android:textSize="20sp"
    26.         />
    27.         <TextView
    28.             android:layout_width="fill_parent"
    29.             android:layout_height="0dip"
    30.             android:layout_weight="1"
    31.             android:id="@+id/bottomtext"
    32.             android:singleLine="true"
    33.             android:ellipsize="marquee"
    34.         />        
    35.     </LinearLayout>
    36. </LinearLayout>
    37.  
    Someone can help me

    thanks in advance.
     

    Advertisement

  2. nokachouik

    nokachouik Member
    Thread Starter
    5

    Nov 16, 2010
    7
    0
    5
    i've tried to set a checkbox manually in my layout.
    I added this just before the last </LineaLayout>

    Code (Text):
    1.  
    2.     <CheckBox
    3.             android:id="@+id/checkbox"
    4.             android:layout_alignParentRight="true"
    5.             android:layout_width="wrap_content"
    6.             android:layout_height="fill_parent"
    7.         />
    8.  
    With this, i have a checkbox for each items in my listview, but when i select an item, some others items are selected too (all eight items to be precise).
    I don't understant why.
     

Share This Page

Loading...