Here is what I do in onCreateView
(in fragment):
NewsAdapter adapter = new NewsAdapter(getActivity(), newsList, R.layout.news_list_item);
newsListView.setAdapter(adapter);
newsListView.setOnItemClickListener(this);
And here is onItemClick
:
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
view.setBackgroundResource(R.drawable.list_item_back_selected);
}
And the problem is when I tap on the first item then the last visible is only highlighted. On the 2nd - 1st and 2nd from the end. 3rd - 2nd, last and 3rd from the end etc.
I checked that view
is a really the item was clicked by looking inside mChild
array. Currently I can't figure out the reason. Do you have any ideas? Let me know if more datailed code is required. Thanks in advance.
The application was tested on 10 inches tablet emulator, Android 2.3.3