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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:27:02+00:00 2026-06-16T05:27:02+00:00

I am using custom adapter which I use for my ListView . After creating

  • 0

I am using custom adapter which I use for my ListView. After creating ArrayList

WifiListAdapter<WifiListItem> adapter = new WifiListAdapter<WifiListItem>(
            this, R.layout.listview_item_text, listItems);

I have the following code in my app:

    ListView listView = (ListView) findViewById(android.R.id.list);
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    listView.setAdapter(adapter);

However, when I try to click on the checkbox, nothing happens. So I have to manage toggling checkbox state manually.

    protected void onListItemClick(ListView l, View v, int position, long id) {
    CheckedTextView checkBox = (CheckedTextView) v
            .findViewById(R.id.text1);
    if (checkBox != null) {
        checkBox.toggle();

Then it works. ( before that I have to remove setChoiceMode method call )

So what could be the problem? Why there is no effect?

my R.layout.listview_item_text.xml

    <TextView
    android:id="@+id/topText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textSize="22sp"
    android:paddingTop="7dp"
    android:textColor="?android:attr/textColorPrimary"/>

<TextView
    android:id="@+id/botText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textSize="17sp"
    android:paddingTop="2dp"
    android:paddingBottom="7dp"
    android:textColor="?android:attr/textColorTertiary"
 />

In my adapter I inflate checkbox layout with the following code:

                convertView = mInflater.inflate(
                        R.layout.listview_item_checkbox, null);

            CheckedTextView checkbox = ((CheckedTextView) convertView
                    .findViewById(R.id.text1))

listview_item_checkbox.xml

    <CheckedTextView
    android:id="@+id/text1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_vertical"
    android:textSize="22sp"
    android:paddingTop="7dp"
    android:paddingBottom="7dp"
    android:checkMark="?android:attr/listChoiceIndicatorMultiple"
     />
  • 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-16T05:27:04+00:00Added an answer on June 16, 2026 at 5:27 am

    Instead of your code:

    if (checkBox != null)
            checkBox.toggle();
    

    Try something like this:

    if (checkBox != null) checkBox.setChecked(l.getCheckedItemPositions().get(position));
    

    If you can – improve yur code (create CheckableFrameLayout as parent layout of your List Item). ListView keep BooleanSparseArray of checked positions (you can get it with method getCheckedItemPositions()). In code (grepcode) it set View checked or not by itself only if View is implementing Checkable. If create CheckableFrameLayout and sat as main parent, you do not have to handle these cases in the adapter.

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

Sidebar

Related Questions

I am using Custom Adapter to populate a listview which is reading from the
I'm trying to delete items from a ListView using a custom adapter which extends
I have a custom listview by using an adapter which has alternate background color.
I am displaying images and text to a listview using a custom adapter, when
I have a custom adapter extended from the SimpleCursorAdapter. Using this I'm binding a
I'm new in android.I'm using listview which contains images and textview.I want to add
I've got a ListView and a custom adapter. I also got a layout for
I am reading from a database into a listview using a custom cursor adapter.
I have a ListView which uses a custom adapter to display rows of data.
I'm using a ListView with a custom adapter to receive a JSON response and

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.