开发者

HOW TO refresh the content of a single row in my ListView using OnItemClick

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开发者_StackOverflow社区);
    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?


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

Now update the view with the new values.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜