Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have make a app using sqlite table.
The sqlite table is loaded into listview with multicolumns either by quering all of data or for specific values.
On cklik of a row in listview , it opens new activity to edit data.
The new data are saved on sqlite table correctly.
I can't refresh the view only for the row/column i have change but only by quering again the adapter.
Is there a way to do that?

What I have tried:

protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
if (resultCode == Result.Ok)
{
int IdReturned = Convert.ToInt32(data.GetStringExtra("Id_Ret"));
int ValueReturned = Convert.ToInt32(data.GetStringExtra("CurMtr_Ret"));
int ListidReturned = Convert.ToInt32(data.GetStringExtra("Listid"));
db.UpdateRec(IdReturned, ValueReturned, 1);
ICursor Rcursor = (ICursor)listView.GetItemAtPosition(ListidReturned);
db_cursor = db.FindSingleRec(IdReturned);
listView.Adapter = (IListAdapter)new MtrCursorAdapter(this, db_cursor, true);
((BaseAdapter)listView.Adapter).NotifyDataSetChanged();
}
}
Posted
Updated 24-Jun-16 4:54am

1 solution

You need to notify the view that the data has changed and needs the view to be refreshed. See How to correctly implement BaseAdapter.notifyDataSetChanged() in Android[^].
 
Share this answer
 
Comments
Member 12582622 24-Jun-16 12:20pm    
I'm sorry, but i can't understand it.
Maybe I'm too new in this. Your approach is in java?
I have use my adapter to fill my listview with rows and columns from sqlite database table.
I can't figure it out what to do next so the view shows the altered data.

Thanks for your patience
Richard MacCutchan 24-Jun-16 12:26pm    
Well that link explains it, and gives you a full code implementation; I cannot see what more we can offer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900