【发布时间】:2012-09-13 06:06:19
【问题描述】:
我使用创建的自定义 XML 文件在 ListActivity 中绑定我的 db 光标。 XML 文件中的每个项目都有 2 个按钮。我想捕捉按钮的点击事件和在列表中的位置。
这是我的 XML 文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="@+id/smListName" android:paddingTop="2dip" android:paddingBottom="3dip" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:textSize="22dip" />
<Button android:id="@+id/smListCompleted" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_gravity="right" android:textStyle="bold" android:textColor="#0000ff" />
<Button android:id="@+id/smListNotCompleted" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_gravity="right" android:textColor="#ff0000"
android:textStyle="bold" />
</LinearLayout>
这就是我的绑定方式
db = openOrCreateDatabase("ITC", MODE_PRIVATE, null);
Cursor outlets = db.rawQuery("Select s.salesmanid as _id, s.name ...", null);
this.setListAdapter(new SimpleCursorAdapter(this, R.layout.salesmanlist, outlets, new String[] { "name", "complete", "incomplete" }, new int[] {
R.id.smListName, R.id.smListCompleted, R.id.smListNotCompleted }));
db.close();
我没有使用自定义适配器。现在我想捕捉 smListNotCompleted 和 smListCompleted 的点击以及行位置。
谢谢
【问题讨论】:
标签: android listadapter