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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:17:24+00:00 2026-05-27T22:17:24+00:00

In my application, I have a list. This list includes some texts and a

  • 0

In my application, I have a list. This list includes some texts and a checkbox. In Xml definition of list, If I put android:focusable="true" then I can click it and change it’s status from checked to not checked and vice versa. But I can’t change its status when I click on its row.

If I put android:focusable="false" the story will exchange. If I choose row, I can change the status of checkbox while if I click on it, nothing will change. I need regardless of clicking on row or checkbox, status of chackbox changes. If i click on checkbox it’s status will change but my list doesn’t aware of this changes therefore, onListItemClick() not execute.

I tried to add another element android:enabled="false". But UI is not user friendly. Also, when I click on checkbox its status is not changed.

What is your suggestion?

This is xml code of list:

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <RelativeLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="?android:attr/listPreferredItemHeight"
            android:padding="6dip" >

            <CheckBox 
                android:id="@+id/checkbox"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:layout_alignParentBottom="true"
                android:layout_marginRight="6dip"
                android:layout_marginLeft="4px"
                android:focusable="false" />

.
.
.

and in code: Flag and planId are String Array.

private String[] flag = new String[50];
private String[] planId = new String[50];

@Override
    public void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        Log.i("List Clicked:", "******");

        //Toggle CheckBox from not selected to selected and vice versa.
        if(flag[position] == "true")
            flag[position] = "false";
        else
            flag[position] = "true";

        //Keep this CheckBox selected and clear the rest.
        for(int i=0; i<position; i++)
            flag[i] = "false";
        for(int i=position+1; i<flag.length; i++)
            flag[i] = "false";

        //If checkBox is selected show dialog if cleared don't show
        if(flag[position] == "true")
            //alertDialog.show();
            dialog.show();

        //Extracting Plan Id
        subscriptionPlanId = planId[position];
    }

screen capture:

enter image description here

=======>
Update:

//*********************
    //  RowModel Class
    //*********************
    private class RowModel{
        TextView title;
        TextView description;
        CheckBox checkbox;
    }

    //*********************
    //  ListAdapter Class
    //*********************
    private class ListAdapter extends ArrayAdapter<String>{

        public ListAdapter(Context c) {
            super(c, R.layout.infindo_listformat, list);
        }

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

            if(row == null){
                LayoutInflater inflater = getLayoutInflater();
                row = inflater.inflate(R.layout.infindo_listformat, parent, false);

                holder = new RowModel();
                holder.title = (TextView) row.findViewById(R.id.title);
                holder.description = (TextView) row.findViewById(R.id.description); 
                holder.checkbox = (CheckBox) row.findViewById(R.id.checkbox);

                row.setTag(holder);

            } else {
                holder = (RowModel) row.getTag(); 
            }

            holder.title.setText(titels[position]);
            holder.description.setText(descriptions[position]);
            String s = flag[position];
            if(s.equalsIgnoreCase("false"))
                holder.checkbox.setChecked(false);
            else
                holder.checkbox.setChecked(true);

            return(row);
        }
    }
  • 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-27T22:17:25+00:00Added an answer on May 27, 2026 at 10:17 pm

    Sorry I answer my question here because above is so messy and confusable. For future reference I put my answer here.

    Question: When I click on checkbox in a list, its status will change but onListItemClick() method, doesn’t aware of this change and therefore this method will not run.

    Answer: In XML elemnts of checkbox, just set clickable of this item to false. 🙂 the problem is solved. In my case the XML is:

    <Check
    android:id="@+id/checkbox"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_alignParentBottom="true"
    android:layout_marginRight="6dip"
    android:layout_marginLeft="4px"
    android:focusable="false"
    android:clickable="false" />
    

    Now, regardless of clicking on row or checkbox, onListItemClick() method will call.

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

Sidebar

Related Questions

I am creating an application that will have a list of items that can
Imagine the typical type of application where you have a list of items with
I have a List in the main application and I am trying to access
I have dropdown list control in one of my application and when I add
In the entry form of my wpf application, I have a list of buttons
I have an application that shows a list of items. The user can click
I have an application that has a list of buttons and has customized tooltips.
I have an array list of objects in my application. private static ArrayList<Player> userList=new
I have an application with multiple "pick list" entities, such as used to populate
I have a linked list, which stores groups of settings for my application: typedef

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.