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 6990727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:23:41+00:00 2026-05-27T19:23:41+00:00

I have a list view where the list items have the following background drawable

  • 0

I have a list view where the list items have the following background drawable

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@color/transparent" />
    <item android:state_pressed="true"
    android:drawable="@drawable/collection_item_gradient" />
</selector>

When the list item is pressed, it applies the gradient. However, if the user then initiates a multitouch event (say by putting an additional finger down somewhere outside the list view) it is possible that the list item remains in the pressed state until another touch event is received by the list view.

Is there a way around this?

  • 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-05-27T19:23:42+00:00Added an answer on May 27, 2026 at 7:23 pm

    It depends somewhat on what you are looking to accomplish…

    If you are looking to display a third background type when the user has two fingers down, there is no drawable state that you can reference directly to accomplish. You would have to co-op one of the existing states that is not often used in touch mode (such as the selected state), and implement a custom touch handler on the list item’s object to set that state. For example, implement onTouchEvent() in each list item’s view (or add an onTouchListener() if you don’t have a custom class), look for the ACTION_POINTER_DOWN event to tell you that a second finger came down, and call setSelected() on the view to trigger a drawable you have set for the android:state_selected in your <selector>.

    If you just want the state to clear under this case, you can cancel the touch event when more than one finger is detected. In this case, you are looking at customizing the ListView.onInterceptTouchEvent() method to look for the ACTION_PONTER_DOWN event and return true. This will teach the ListView to steal the touch back from it’s child item with a second finger, which will cancel the pressed state of the list item. Make sure to call back through to super in this case so you don’t break all the existing logic ListView uses for scrolling, etc.

    Beware of cases where the existing AbsListView implementation may get in your way here. For example, the current implementation of onIntercepTouchEvent() looks for ACTION_POINTER_UP in order to switch the main touch finger from the first to the second. This behavior may cause strange artifacts in your customization if you aren’t aware of it.

    HTH.

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

Sidebar

Related Questions

I have the following layout: <?xml version=1.0 encoding=utf-8?> <FrameLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical android:background=#EAEAEA>
I've been following these 2 tutorials to setup a list & click events: http://mfarhan133.wordpress.com/2010/10/14/list-view-tutorial-for-android/
I have a list view with over 100 items. Each of these items show
I have created a list view that displays the names and dates of items
I have created a TableView(Grouped Table View). And I can list the items in
I have the following XML file getting populated via list view. I can't get
I have an android activity that consists of a List View and a Text
I have a navigation based app. The root view is a list of items.
In my application, I have list view. Selecting another item in it, triggers an
I have a listview with 200 items. I use a custom view for each

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.