简体   繁体   中英

Display data from database in listview and delete checked item

Can I know how to display the name of item from database with checkbox beside which enable the users to delete the item when the checkbox is ticked.

I have gone through several articles that mentioned about this but most of the articles are not displaying the data from database. They mentioned about the adapter but I am not very sure how does it function.

Can anybody explain to me:

  • how does the adapter work between listview, textview and checkbox
  • how to detect and delete the selected item when the checkbox is ticked

Below are the two different .xml that I have done:::

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/wishlistln"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp" >

<CheckBox
    android:id="@+id/wishlistcb"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:text="" />

<TextView
    android:id="@+id/wishlist"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:layout_marginLeft="10dp"
    android:textSize="16sp" />

  </LinearLayout>

    <ListView
    android:id="@android:id/list"
    android:layout_width="wrap_content"
    android:layout_height="400dp" />

Thank you.

是有关ListViewAdapter的不错的教程,它显示了如何显示数据以及如何处理ListView上的事件

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM