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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:09:13+00:00 2026-05-30T14:09:13+00:00

In my listview there is a checkbox, textviews and an imageview. When I click

  • 0

In my listview there is a checkbox, textviews and an imageview. When I click on an item, the onclicklistnere is not working. I know this is because the checkbox has its own listener and it overrides the listview onclicklistener. Fine. When I set

android:focusable="false"
android:focusableInTouchMode="false"

in the checkbox, I can click on the list item but the checkbox becames orange as well (like the item).

So this is a half solution, does anyone know a better one?

This is the class:

    public class ListViewTutorial2Activity extends Activity {

    SimpleAdapter mSchedule;
    ListView list;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        list = (ListView) findViewById(R.id.SCHEDULE);

        ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("train", "101");
        map.put("from", "6:30 AM");
        map.put("to", "7:40 AM");
        mylist.add(map);
        map = new HashMap<String, String>();
        map.put("train", "103(x)");
        map.put("from", "6:35 AM");
        map.put("to", "7:45 AM");
        mylist.add(map);
         mSchedule = new SimpleAdapter(this, mylist, R.layout.row,
                    new String[] {"train", "from", "to"}, new int[] {R.id.TRAIN_CELL, R.id.FROM_CELL, R.id.TO_CELL});
        list.setAdapter(mSchedule);

        list.setOnItemClickListener(new OnItemClickListener() 
        {
        @Override
        public void onItemClick(AdapterView<?> a, View v, int position, long id) {
             Object o = list.getItemAtPosition(position);
            }
        });
    }
}

and row.xml:

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:paddingTop="4dip"
     android:paddingBottom="6dip"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:orientation="horizontal">
    <CheckBox
        android:id="@+id/check"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:clickable="true"
        android:descendantFocusability="beforeDescendants">
    </CheckBox>
     <TextView android:id="@+id/TRAIN_CELL"
         android:layout_width="50dip"
         android:layout_height="wrap_content"/>

     <TextView android:id="@+id/FROM_CELL"
         android:layout_width="70dip"
         android:layout_height="wrap_content" android:layout_weight="1"/>

     <TextView android:id="@+id/TO_CELL"
         android:layout_width="60dip"
         android:layout_height="wrap_content"  android:layout_weight="1"/>

            <ImageView
        android:id="@+id/icon"
        android:layout_width="22px"
        android:layout_height="22px"
        android:layout_marginLeft="4px"
        android:layout_marginRight="10px"
        android:layout_marginTop="4px"
        android:src="@drawable/icon" >
    </ImageView>
</LinearLayout>
  • 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-30T14:09:14+00:00Added an answer on May 30, 2026 at 2:09 pm

    You don’t need to set any special properties on the CheckBox to do this. In the ListView, however, try the following:

    android:clickable="true"
    android:descendantFocusability="beforeDescendants"
    

    If that doesn’t work, you’re probably doing something wrong elsewhere.

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

Sidebar

Related Questions

I have a ListView where each item has a checkbox. Initially there are no
I know there are lots of questions related to Custom ListView with CheckBox but
I made a listview that has three textviews and a checkbox and put it
My app shows a listview, where every item has a checkbox and 2 labels;
I have a listview with each row having a checkbox, imageview and text view
I have an ImageView on top of a ListView and whenever there is a
I have a ListActivity; and for each item in the ListView there is a
I have a .net 4 asp.net website. There is a listview with a checkbox
Is there a ListView (ListBox) or similar component that allows me to easily drop
Is there any way to force a listview control to treat all clicks as

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.