Question

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?

Was it helpful?

Solution

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

Now update the view with the new values.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top