Skip to content Skip to sidebar Skip to footer

Listview With Rows Containing A Linearlayout

I'm trying to implement a list using the ListView, which contains rows built with a LinearLayout. This LinearLayout is composed of a checkbox and a textview. The layout of the row

Solution 1:

In this case, you need to use android.R.id.text1, as you're referencing the built in android ID (@android:id was the clue).

setListAdapter(newArrayAdapter<String>(this, R.layout.tasks_list_row, android.R.id.text1, items_task));

There isn't much advantage to doing this, unless you're using built in layouts, such as android.R.layout.two_line_list_item

Solution 2:

try with the android default textview id; android.R.id.text1

Solution 3:

Give an id to your LinearLayout android:id="@android:id/tasks_list_row" and use this instead

setListAdapter(newArrayAdapter<String>(this, R.id.tasks_list_row, items_task));

Each item will have the xml that you have specified. You could instead use a CheckedTextView which combines a TextView with a CheckBox.

Post a Comment for "Listview With Rows Containing A Linearlayout"