Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8679355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:57:04+00:00 2026-06-12T20:57:04+00:00

I have a ListView and with a Timer I control the scroll movement of

  • 0

I have a ListView and with a Timer I control the scroll movement of this list by calling smoothScrollToPositionFromTop(position, offset, duration). The ListView has a listener for OnItemClickListener.

If an item is clicked while the smooth scroll is happening, the scroll stops but the onItemClick event is not triggered. In order to do so you need to click again on the item.

I want to know how to override this behaviour. I mean, if I click on an item while the smooth scroll is happening, apart from stopping the scroll, I want to trigger onItemClick on the item clicked.

I really don’t know if there is an easy way to do this. I tried with a GestureDetector for the OnTouchListener of the list and I listen to the onSingleTapConfirmed in order to call performClick in there, but I don’t know how to get the position of the item being press from the MotionEvent.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T20:57:05+00:00Added an answer on June 12, 2026 at 8:57 pm

    I finally found a solution by using the GestureDetector:

    final GestureDetector gestureDetector = new GestureDetector(MyActivity.this, 
      new GestureDetector.SimpleOnGestureListener(){
        public boolean onSingleTapConfirmed(MotionEvent e) {
            int position = listView.pointToPosition((int)e.getX(), (int)e.getY());
            if(position != ListView.INVALID_POSITION){
                listView.playSoundEffect(SoundEffectConstants.CLICK);
                //onItemClick code goes here
                //or call listView.performItemClick
                return true;
            }
            return false;
        };
    });
    
    listView.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return gestureDetector.onTouchEvent(event);
        }
    });
    
    listView.setSelector(android.R.color.transparent);
    

    In my case, I added what I was doing in onItemClick inside onSingleTapConfirmed and removed the OnItemClickListener from the list. That’s why I also added the playSoundEffect function to simulate the click.

    In the last line I disable highlight on ListView click since lines got highlighted only when the smooth scroll was not happening. By disabling it I get the same behaviour for every click.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListView Control in WindowsForm and also this Listivew has a checkBox
I have a listview control, to this control I am adding rows which contain
I have a Winforms App in C# with a ListView control. This ListView shows
I want to tap a control on the screen and have the ListView scroll
I have a ListView to display category items, below this, I have a control
I have listview control.There is an option to remove selected items.After the user removes
I have ListView that has the following EditItemTemplate: <EditItemTemplate> <tr style=> <td> <asp:LinkButton ID=UpdateButton
I have ListView in my project which has ListItems as in the form of
I have a HyperLink control in a ListView, and I need to pass a
I have created a compound control that I am reusing in multiple activities. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.