0

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();
                    }



                }
            });
rahul
  • 2,613
  • 8
  • 32
  • 55
  • Are you looking for listview with sticky headers? – AlexBalo Jul 21 '14 at 07:40
  • Yes its similar to that but in sticky header the header is separate with the row of listview and I want to a listview which will have an image and an textview over the image(similar to stack).for that I posted my problem at http://stackoverflow.com/questions/23782773/how-to-add-sticky-header-in-listview-with-background-image-on-list-row-in-androi but didn't get any solution – rahul Jul 21 '14 at 07:43
  • Seems that someone posted a solution in the link you sent me... – AlexBalo Jul 21 '14 at 07:48
  • I tried that solution but didn't work for me, now the new work if perfect solution for me I just need to resolve the scrolling issue, apart from that everything is working perfect for me – rahul Jul 21 '14 at 07:50
  • Check this : https://github.com/beworker/pinned-section-listview. This will give you idea of how to implement it – VVB Jul 21 '14 at 07:56

0 Answers0