How do I refresh a ListView in Android - onItemClick, Alert shown with Edit Text
I have a a list view that shows:
tag : 10 tagb : 20
When I click on an item, I get an Alert asking to change a value (EditText) I set the value and click ok
- How can I refresh the listview to show the change
- How can I manually change the row and put the new value there eg tagb : 122?
BTW, The list of itemsand value comes from a result of a REST call I make to a server
Hope this makes sense.
Thanks
Here is the code for the ListView:
setContentView(R.layout.listview); list = (ListView) findViewById(R.id.list);
adapter = new ListViewAdapter(this, alarmName, deviceName, alarmDate,
alarmSev);
list.setAdapter(adapter);
adapter.notifyDataSetChanged();
list.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
AlertDialog.Builder adb = new AlertDialog.Builder(
AlarmsTab.this);
adb.setTitle("Acknowledge Alarms");
adb.setMessage("Do you want to Acknowledge this Alarm? " + "\n"
+ alarmName.get(arg2));
alarmpos = alarmName.get(arg2);
adb.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
CloseAlarm(asset, model, alarmpos);
}
});
adb.setNegativeButton("No",
new Dial开发者_C百科ogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
adb.show();
}
});
getAlarmsForAsset(asset);
adapter.notifyDataSetChanged();
}
Make sure your edit gets propagated into your data otherwise, when you do notifyDataSetChanged(); the list adapter will not pickup the right data upon refreshing.
That's where I would start looking first.
精彩评论