Reputation: 67
I am having a list view with text and a button. The contents of the listview(the text) are fetched from the SQLite database. I have implemented the code such that, if anyone clicks the button, the corresponding flag of that list item changes in the database table. My intention would be, as soon as the flag is changed in the database table, the corresponding list item should disappear from the list.
Currently, I'm able to change the flag value for the list item (successfully updating in the corresponding column of the table), but the list item remains in the list view until I re-open the app. The list item then disappears as desired.
Is there a way such that as soon as I click the button, and as the flag value is changed at the background, the list refreshes and show me only other items of the list.?
Your help will be much appreciated. Thanks in advance.
Upvotes: 0
Views: 1781
Reputation: 67
Thanks all for your responses. I have tried to do it in android way, but seems to be a bit complex. Hence inorder to refresh the list view after updating the list I have re-called the activity using intents so that I'll get a fresh list view with added or deleted list entries.
Hope I'll find other android way of solutions soon.
Upvotes: 0
Reputation: 11230
Upvotes: 0
Reputation: 4842
Generally, for a ListView, you have to prepare an adapter for the ListView to provide the content of every item in the ListView.
The basic idea is that in order to refresh the listview, you have to call adapter.notifyDataSetChanged()
to request the refreshment.
Upvotes: 0