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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:13:06+00:00 2026-06-10T06:13:06+00:00

I have a custom ListView with Checkboxes and 3 TextViews. Here is my layout

  • 0

I have a custom ListView with Checkboxes and 3 TextViews. Here is my layout for list item:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/listviewitem_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<CheckBox
    android:id="@+id/faxCheckBox"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:focusable="false"
    android:focusableInTouchMode="false" />

    <LinearLayout android:orientation="horizontal"
        android:id="@+id/faxbox_item_first_row"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/faxCheckBox"
        android:paddingTop="8dp"
        android:paddingLeft="8dp"
        android:paddingRight="8dp">
        <TextView android:id="@+id/fax_number_textView"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:lines="1"
            android:ellipsize="start"
            android:textSize="12sp"
            android:paddingRight="5dp"/>
        <TextView android:id="@+id/fax_send_date_textView"
            android:layout_width="wrap_content"
            android:layout_weight="0"
            android:layout_height="wrap_content"
            android:textSize="9sp"/> 
    </LinearLayout>
    <TextView android:id="@+id/more_fax_info_textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="9sp"
        android:textColor="@color/gray"
        android:layout_toRightOf="@id/faxCheckBox"
        android:layout_below="@id/faxbox_item_first_row"
        android:paddingLeft="8dp"/>
</RelativeLayout>

I have also a custom arrayadapter for the listview:

private class MyAdapter extends ArrayAdapter<Order> {
    private ArrayList<Order> mOrders;
    private Context mContext;
    private int mResourceId;

    public MyAdapter(Context context, int resourceId, ArrayList<Order> orders) {
        super(context, resourceId, orders);
        this.mContext = context;
        this.mOrders = orders;
        this.mResourceId = resourceId;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = convertView;

        if (view == null) {
            LayoutInflater vi = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            view = vi.inflate(mResourceId, parent, false);
        }

        final Order order = mOrders.get(position);

        if (order != null) {
            TextView sender = (TextView)view.findViewById(R.id.number_textView);
            TextView date = (TextView)view.findViewById(R.id.send_date_textView);
            TextView moreInfo = (TextView)view.findViewById(R.id.more_info_textView);
            CheckBox checkBox = (CheckBox)view.findViewById(R.id.checkBox);

            final int itemPosition = position;
            final RelativeLayout rowLayout = (RelativeLayout)view.findViewById(R.id.listviewitem_layout);

            view.setTag(order.getId());

            if (sender != null) {
                sender.setText(order.getSender());
            }

             rowLayout.setBackgroundResource(R.drawable.listview_item_selector);

            if (mSelectedIds.contains(order.getId())) {
                rowLayout.setBackgroundColor(Color.parseColor("#9CD7EF"));
            }

            if (date != null) {
                date.setText(Utils.getStringDateForBox(order.getSendDate(), mContext));
            }

            if (moreInfo != null) {
                moreInfo.setText(getResources().getQuantityString(R.plurals.number_of_pages, order.getPages(), order.getPages()));
            }

            if (checkBox != null) {
                checkBox.setTag(order.getId());

                checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

                    @Override
                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                        if (mSelectedIds.contains(buttonView.getTag()) == true) {
                            if (isChecked == false) {
                                mSelectedIds.remove(buttonView.getTag());
                            }
                        } else {
                            if (isChecked) {
                                mSelectedIds.add((Long) buttonView.getTag());
                            }
                        }

                        showHideActionMode();
                        setActionModeTitle();
                        mListView.setItemChecked(position, true);
                    }
                });

                if (mSelectedIds.contains(order.getId())) {
                    checkBox.setChecked(true);
                } else {
                    checkBox.setChecked(false);
                }
            }
        }

        return view;
    }
}

listview_item_selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true"
      android:drawable="@color/blue" />
<item android:state_pressed="true"
      android:drawable="@color/blue" />
<item android:state_selected="true"
      android:state_activated="true"
      android:drawable="@color/light_blue" />
<item android:state_activated="true"
      android:drawable="@color/light_blue" />
<item android:state_selected="true"
      android:drawable="@color/light_blue" />
<item android:state_focused="false" android:state_selected="false" android:state_pressed="false" 
     android:drawable="@android:color/white" />
<item android:drawable="@android:color/transparent" />
</selector>

The problem is, if I press a row, then it changes the background color to blue, but without checkbox, checbox has all the time the orange background color. How can I change it?
Maybe should I everything differently make? I’d like at the best something like in the gmail app on the ICS.

  • 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-10T06:13:07+00:00Added an answer on June 10, 2026 at 6:13 am

    I find only how to make a custom checkbox, but this is not the best solution.

    checbox_selector.xml

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true"
          android:drawable="@drawable/btn_check_off_pressed_holo_light" />
    <item android:state_checked="true"
          android:state_pressed="true"
          android:drawable="@drawable/btn_check_on_pressed_holo_light" />
    <item android:state_pressed="true"
          android:drawable="@drawable/btn_check_off_pressed_holo_light" />
    <item android:state_checked="true"
          android:state_activated="true"
          android:drawable="@drawable/btn_check_on_holo_light" />
    <item android:state_activated="true"
          android:drawable="@drawable/btn_check_on_holo_light" />
    <item android:state_checked="true"
          android:drawable="@drawable/btn_check_on_holo_light" />
    <item android:state_focused="false" android:state_selected="false" android:state_pressed="false" 
         android:drawable="@drawable/btn_check_off_holo_light" />
    <item android:drawable="@drawable/btn_check_off_holo_light" />
    

    and in my list item layout I added that to my checkbox:

    android:button="@drawable/checkbox_selector"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a custom ListView object. The list items have two textviews stacked
I have a custom ListView in which each row.xml looks like this: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
I have list view with custom row layout (list_row.xml) that contains CheckBox element: <TableLayout
I have a custom listview row whose XML has one ImageView and three TextViews
I have a custom listview, i successfully parse the data into a list but
Here's my aproach: I have a custom ListView containing a custom Adapter containing two
I have a custom ListView with two TextViews , I have two string arrays
We have created custom listview by using the Base adapter. List view contains Text
I have a problem with listview which list item contain a checkbox. When i
I have a custom xml file for my listview and then I use an

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.