I am using a listview with an arrayadapter.. and i wish to know how to change an object property directly with an adapter ? without having to remove it and readding it. It is possible ?
Currently i use ..
btnModifierNom.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
int itemPosition = lstPersonnes.getCheckedItemPosition();
selectedItem = lstPersonnes.getItemAtPosition(itemPosition).toString();
String personne = adapter.getItem(itemPosition);
adapter.remove(personne);
personne = txtNouveauNom.getText().toString();
adapter.insert(personne, itemPosition);
adapter.notifyDataSetChanged(); }
});
But its not a very elegant way.. if possible i would love to avoid removing it and reinserting it.
Any ideas ?
Thanks!
Why can’t you just change the value like this:
And if
adapter.notifyDataSetChanged()didn’t work with this, then trylistView1.setAdapter(adapter)to refresh the listview.UPDATE:
Try this: