How to update single row content in my ListView using OnItemClick

I have a ListView with CheckBox. What I'm trying to implement is onItemClick (in my activity), which checks / selects my CheckBox if I click on a line, 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 a row, the ListView is updated due to the notifyDataSetChanged () method

PROBLEM : this method updates the entire ListView, and as a result ScroolBar jumps to the beginning (the user is controlled by the list header), even if the user is at the bottom of the list.

WHAT I NEED : refresh this line with just one click so that the user is not included at the top of the list.

Are there any solutions to this problem?

+4
source share
1 answer

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

Now update the view with the new values.

+3
source

All Articles