Я потратил целый день на попытки загрузить пользовательский ряд.В StackOverflow и в других местах приведено множество примеров того, как привязать флажок к строке данных в представлении списка Android, но все они кажутся неполными.
Вот что у меня есть (строка.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="40dip"
android:orientation="horizontal" android:background="@drawable/row_bk"
android:layout_gravity="center_vertical">
<TextView android:id="@+id/ItemID"
android:layout_weight="0" android:visibility="gone"
android:layout_width="0dp" android:gravity="center"
android:layout_height="wrap_content" />
<TextView android:id="@+id/Title"
android:layout_width="0dp" android:textColor="#666"
android:layout_weight="1" android:layout_height="40dip"
android:padding="5dp" android:gravity="center_vertical"
android:textSize="17dip" />
<CheckBox android:id="@+id/chkCheck" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:focusable="false" android:focusableInTouchMode="false" android:clickable="true"></CheckBox>
</LinearLayout>
В коде у меня есть SimpleCursorAdapter, заполняющий ListView.
Cursor oLoop = db
.rawQuery(
"select _id, title, is_checked from tbl",null);
startManagingCursor(oLoop);
String[] from = new String[] { "_id", "title", "is_checked" };
int[] to = new int[] { R.id.ItemID, R.id.Title, R.id.chkCheck };
SimpleCursorAdapter oList =
new SimpleCursorAdapter (this, R.layout.task_item_row, oLoop, from,
to);
setListAdapter(oList);
Мимо этого, я не совсем уверен, что делать.Если бы кто-то показал мне хороший пример, это было бы здорово.Цель состоит в том, чтобы на самом деле иметь возможность переключать флажки.
Заранее спасибо!Alex