1

How to disable listview touch or click while scrolling listitems. I am doing listview scroll on button click event and i need listview click disable while scrolling. I want to make listview to wheel-view

2 Answers 2

1

Use setOnScrollListener

listview.setOnScrollListener(new OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {

            if (scrollState == SCROLL_STATE_IDLE) {
                isScrolling = false;
            }

        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem,
                int visibleItemCount, int totalItemCount) {
           isScrolling = true;
        }
    });

and in the setOnItemClickListener do that:

listview.setOnItemClickListener(new OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> parent, View view,
            int position, long id) {

        if(!isScrolling){
            //do your code
        }

    }
});
Sign up to request clarification or add additional context in comments.

Comments

0

set OnScrollListener on the listview as below

setOnScrollListener(new OnScrollListener() { 
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    // TODO Auto-generated method stub 
} 

public void onScrollStateChanged(AbsListView view, int scrollState) {
    if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
        Log.i("a", "scrolling stopped...");
         //attach the click listerner here
    } else if(scrollState==OnScrollListener.SCROLL_STATE_TOUCH_SCROLL){
         //remove the click listener here

    } 
}); 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.