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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:34:53+00:00 2026-05-18T04:34:53+00:00

I am new so I may not explain the situation well. Please let me

  • 0

I am new so I may not explain the situation well. Please let me know if you need more info.

I am trying to implement a listview like this:

 [textview][button][checkbox] 
 [textview][button][checkbox]
 [textview][button][checkbox] 
 [textview][button][checkbox] 

I want other checkbox unchecked automatically when I click one of them. So it is like a single choice. I write following codes which can implement multiple choice but when I try to switch it to single choice I got trouble.

in checkBoxOnClickListener I cannot find other (checkbox)view and toggle them. Any suggestion pals? Let me know if you think my express skills poor.

Thank you.

    public class MyAdapter extends SimpleAdapter {

    Map<Integer, Boolean> map;

    LayoutInflater mInflater;

    private List<? extends Map<String, ?>> mList;

    public MyAdapter(Context context, List<Map<String, String>> data, int resource, String[] from, int[] to) {
        super(context, data, resource, from, to);
        map = new HashMap<Integer, Boolean>();
        mInflater = LayoutInflater.from(context);
        mList = data;
        for (int i = 0; i < data.size(); i++) {
            map.put(i, false);
        }
        if (data.get(0).get("value").equals("Male") || data.get(0).get("value").equals("Yes")) {
            map.put(1, true);
        }
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.rapid_diagnosis_row, null);
        }
        TextView textView = (TextView) convertView.findViewById(R.id.multiple_question);
        textView.setText((String) mList.get(position).get("value"));

        CheckBox checkBox = (CheckBox) convertView.findViewById(R.id.multiple_checkbox);
        checkBox.setChecked(map.get(position));

        // save position and checking status into tag
        checkBox.setTag(position);
        checkBox.setOnClickListener(checkBoxOnClickListener);

        return convertView;
    }

    public OnClickListener checkBoxOnClickListener = new OnClickListener() {
        public void onClick(View v) {
            // ((CheckBox) v).toggle();
            boolean checked = ((CheckBox) v).isChecked();
            if (checked) {
                ((CheckBox) v).setChecked(true);
            } else {
                ((CheckBox) v).setChecked(false);
            }
            int p = (Integer) (v.getTag());
            mSimpleAdapter.map.put(p, checked);

                            // this cannot works, helppp
            ListView lv = ((ListView) (v.getParent().getParent()));
            (CheckBox) cb = lv.findViewWithTag(1);
            cb.toggle();
                   .....................

……………
}
};
}

  • 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-18T04:34:54+00:00Added an answer on May 18, 2026 at 4:34 am

    Is the problem that findViewWithTag(1) is returning null? It might be that findViewWithTag() does not recursively search for your tag. If you go up parent twice that puts you at your ListView and findViewWithTag() will then be looking at the layout objects to be tagged.

    You should go through each of the ListView‘s children and then find the check box each one holds. It’s hard to tell from the code snippet here, but why are you using run time set Tags to try to find your check boxes rather than IDs?

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

Sidebar

Related Questions

Hopefully I can explain this well enough, but please let me know if more
First, I'll explain the situation and the logic that I'm trying to implement: I
The title may not really explain what I'm really trying to get at, couldn't
Ok Title may not be clear so let me explain. I have 2 classes,
i new to neko vm. may i know in order to use it, i
I'm new to Django and coming from Rails, so that may explain my odd
Okay the question title may not have made sense... mostly because I don't know
Let me explain, I've got several floats in a parent div, it may be
The title of my question may be unclear, so let me explain what's the
This may be the wrong place but this is new to me. I did

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.