Vilasmati Hanjagi
Vilasmati Hanjagi

Reputation: 20

How do I delete item from listview I used ArrayAdapter<String> to display on listview

Can any one tel me how to delete an item from listview .I used to database to store the content which has displaying in listview.To display on listview I make use of ArrayAdapter .Now I want to delete item from listview .Actually it's deleting item only when clear database and restarted activity.Please help me to get solution.

Upvotes: 0

Views: 519

Answers (2)

Jim Corriveau
Jim Corriveau

Reputation: 1

Does this help?

void Reload()
{
    ArrayAdapter adapter= new  ArrayAdapter(context, ...);
    listView.setAdapter(adapter);
}

Upvotes: 0

Narendra Pal
Narendra Pal

Reputation: 6604

If you want to delete any item from the listview then delete the source of adapter from where you are setting the data to the adapter and showing into listview.

For example,

I am setting the ArrayList<String> to the ArrayAdapter adapter I am considering the data is collected into the arrayList.

Now to Delete:

arrayList.remove(pass the position here)

And then

adapter.notifyDataSetChanged()

Hope this help.

Upvotes: 1

Related Questions