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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:50:12+00:00 2026-06-03T05:50:12+00:00

I have listview item like below <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=match_parent android:layout_height=60dp android:orientation=horizontal android:descendantFocusability=blocksDescendants > <TextView

  • 0

I have listview item like below

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="60dp"
    android:orientation="horizontal"
    android:descendantFocusability="blocksDescendants"
    >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />

    <CheckBox
        android:id="@+id/checkBox1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/music_list_item_checkbox_bg"
        />
</LinearLayout>

music_list_item_checkbox_bg.xml is a selector which will show different drawable depending the different state.

<selector xmlns:android="http://schemas.android.com/apk/res/android" >

    <item 
          android:state_pressed="false"
          android:state_selected="true"
          android:drawable="@drawable/btn_checkbox_check_untapped" />

    <item android:state_selected="true" 
          android:state_pressed="true"
          android:drawable="@drawable/btn_checkbox_check_tapped" />

    <item android:state_selected="false"  
          android:state_pressed="false"
          android:drawable="@drawable/btn_checkbox_uncheck_untapped" />

    <item android:state_selected="false"  
          android:state_pressed="true"
          android:drawable="@drawable/btn_checkbox_uncheck_tapped" />

</selector>

When i pressed the item in the listview and left the touch screen inside the item, the drawable depending on the different state is right.

Question: But if i pressed the item and move the finger horizontally out of the item (The X of touch point is between the top and bottom of the item), then left the screen, the drawable of the checkbox will remain in the state of pressed. (If the X of touch point is out of the top and bottom of the item, the state is right).

I tried add android:duplicateParentState="true" to the checkbox to get the same state with the parent, but it not works.

I’m confused, Anyone have some ideas?

Edited

I tried implements onTouch and onIntercept in the item before, but only can receive action down, if i return super.onTouch(MotionEvent event). Only return true, then the sequence event will received, but the onItemClick of listview could’t worked.
I try to read the onTouch code snippet in the AbsListview to figure out how to resolve the problem, i found sometimes the press status of child(item) will not to clear to false by calling child.setPressed(false) which depending on the different touch mode.

I really really want an solution!!!

  • 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-03T05:50:14+00:00Added an answer on June 3, 2026 at 5:50 am

    I solve the problem but maybe not a good solution or official solution.

    I use my own MyListView class extends from ListView instead of the SDK ListView and receive the ACTION_UP and ACTION_CANCEL in its onTouchEvent, then set the press state of the item to false manually. More details to see the below code.

    @Override
    public boolean onTouchEvent(MotionEvent event)
    {
        boolean handled = super.onTouchEvent(event);
        Log.d("test", "event " + event.toString());
        int action = event.getAction();
    
        switch (action)
        {
        case MotionEvent.ACTION_DOWN:
            m_downPosition = pointToPosition((int)event.getX(), (int)event.getY());
            Log.d("test", "The down position " + m_downPosition);
            break;
    
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            int position = m_downPosition - getFirstVisiblePosition();
            View child = INVALID_POSITION != m_downPosition ? getChildAt(position) : null;
            if (null != child)
            {
                child.setPressed(false);
            }
            break;
    
        default:
            break;
        }
        return handled;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple list with a listselector like so. <ListView android:id=@+id/list android:layout_width=fill_parent android:layout_height=fill_parent
I have item container style for list view like below : <ListView.ItemContainerStyle> <Style> <Setter
I have an android listview filled with items. Every item has a button. This
I have a background color applied to a ListView <style name=CKButtons> <item name=android:windowBackground>@color/window_background</item> </style>
I have this in res/values/styles.xml <style name=ListViewRowBorder > <item name=android:width>1dp</item> <item name=android:color>@color/listview_row_stroke_color</item> </style> I
I have a Listview and a button like this Below is the code I
I have a ListView with separate headers.like..Today events is header and below of that
I currently have a TextView sitting below a ListView and would like to theme
I have a ListView item in my application. The scroll position does not get
I have a listview and each item has a title, some info, and a

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.