我现在使用此代码为我简单的ListView:如何使用CheckBox和Image制作ListView?
final ListView lv = (ListView)findViewById(R.id.apps_list);
lv.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, myString.split("\n")));
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
}
});
和布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
style="?android:attr/listSeparatorTextViewStyle"
android:id="@+id/separator_apps"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/apps" />
<ListView
android:id="@+id/apps_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_below="@+id/separator_apps" >
</ListView>
</RelativeLayout>
但我需要的图像和CheckBox添加到每个行本 ListView控件,可能有人给我一个很好的例子?
http://www.vogella.de/articles/AndroidListView/article.html – 2012-02-17 12:24:28
提到此:http://stackoverflow.com/questions/4797926/how-to-make-a-listactivity-with- custom-list-item-with-nested-clickable-button.It类似于您problem.you只需要通过复选框,并通过TextView的图像来替换按钮。 – Hiral 2012-02-17 12:25:11
谢谢,我会看看它。 – Adam 2012-02-17 12:27:29