4

I have a ListView with a CheckBox. What I am trying to implement is an onItemClick (in my activity) that check/select my CheckBox if I click on the row, as you can see below:

@Override
public void onItemClick(AdapterView<?> parent, View view,
        int position, long id) {
    MyItem row = ListofRows.get(position);
    row.setSelected(true);
    myAdapter.notifyDataSetChanged();
}

When I click in the row, the ListView is refreshed because of the method notifyDataSetChanged()

THE PROBLEM IS: this method refreshes the whole ListView and as a result, the ScroolBar goes to the beginning (the user is driven to the header of the list) even if the user is at the bottom of the list.

WHAT I NEED IS: Refresh just this single clicked row so the user won't be driven to the beginning of the list.

Are there any solutions to this problem?

marcelosalloum
  • 3,481
  • 4
  • 39
  • 63

1 Answers1

3

use the selected index View v = getListView.getChildAt(index);

Now update the view with the new values.

blessanm86
  • 31,439
  • 14
  • 68
  • 79