I have a main layout in which there is a listview(id is "lv") and a textview(id is tv_main). listview has textview(id is tv_item) in its row. When I scroll listview then tv_main should replace text with first listview visible item's textview which is tv_item. I did everything but the problem is that when I scroll listview then I can not scroll the listview again until it stops from scrolling. I implemented onscrollListener of listview in the getView of baseadapter. Can anybody tell me when am I wrong and what should I do to resolve this issue. I am posting my code also.
lv.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView arg0, int scrollState) {
// TODO Auto-generated method stub
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
// TODO Auto-generated method stub
int post = lv.getFirstVisiblePosition();
System.out.println("position item id " + adapter.getItemId(post));
System.out.println("position " + post);
System.out.println("position view " + view.getId());
System.out.println("position total " + totalItemCount);
if (holder.tv_item.getText().equals(arr[post])) {
System.out.println("position matched");
holder.tv_item.setVisibility(View.INVISIBLE);
tv_main.setText(arr[post]);
adapter.notifyDataSetChanged();
}else {
holder.tv_item.setVisibility(View.VISIBLE);
adapter.notifyDataSetChanged();
}
}
});