Question

As far as I know, the ListView embeds CheckedTextView to form the list, but every CheckedTextView has only one TextView and a CheckBox. What I want to do is adding some TextViews to the CheckedTextView, like this:


TextView | TextView | TextView | CheckBox| ---- CheckedTextView


How to customize the CheckedTextView? Any help will be appreciated!

Was it helpful?

Solution

For that you need to create a custom LinearLayout that implements Checkable and the create your row.xml using that custom LinearLayout which will work as Checkable. Here is a nice tutorial explaining the same with an example.

OTHER TIPS

I recommend creating a custom layout for your ListView, perhaps:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/text1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TextView
        android:id="@+id/text2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TextView
        android:id="@+id/text3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <CheckBox 
        android:id="@+id/checkbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</LinearLayout>

Take the time to give this layout some personality. Now you can use a SimpleAdapter or SimpleCursorAdapter to bind unique strings to each TextView.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top