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

  • Home
  • SEARCH
  • 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 8285687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:31:52+00:00 2026-06-08T11:31:52+00:00

Above shown is my custom listview with TextViews and RadioGroup. Based on whether the

  • 0

enter image description here

Above shown is my custom listview with TextViews and RadioGroup. Based on whether the item status is “pending” or “served” I update the pending items-TextView (in red, on top).
Everything is working as expected, and I am able to retain the RadioGroup selections on scroll.

However, when I scroll, the pending Items TextView does not retain its value. It changes whenever the list scrolls. Here is my getView method.

public View getView(final int position, View convertView, ViewGroup parent) 
{
    System.out.println(" --- position ---"+position+" --- isChecked[position] --- "+isChecked[position]);

    ViewHolder viewHolder = null;
    if(convertView == null)
    {

        convertView = layoutInflater.inflate(R.layout.order_status_listview_row, null);
        viewHolder = new ViewHolder();
        convertView.setTag(viewHolder);
    }
    else
    {
        viewHolder = (ViewHolder)convertView.getTag();
        convertView.setTag(viewHolder);
    }

    viewHolder.itemName = (TextView)convertView.findViewById(R.id.textview_order_status_item_name);
    viewHolder.itemQuantity = (TextView)convertView.findViewById(R.id.textview_order_status_item_quantity);
    viewHolder.radioGroup = (RadioGroup)convertView.findViewById(R.id.radiogroup_order_status_dialog);

//      isUserChanged[position] = false;
    viewHolder.radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() 
    {           
        public void onCheckedChanged(RadioGroup group, int checkedId) 
        {
 //             if(isUserChanged[position])
            {
                switch(checkedId) 
                {
                    case R.id.radiobutton_served:
                         System.out.println(" --- radiobutton_served ---"+" position "+position+" isChecked[position] "+isChecked[position]);
                         count--;
 //                          countView.setText(DataHelper.getAppropriateCountValue(count));
                         isChecked[position] = true;
                         break;

                    case R.id.radiobutton_pending:
                         System.out.println(" --- radiobutton_pending ---"+" position "+position+" isChecked[position] "+isChecked[position]);
                         isChecked[position] = false;
                         count++;
 //                          countView.setText(DataHelper.getAppropriateCountValue(count));
                         break;             
                }
                countView.setText(DataHelper.getAppropriateCountValue(count));

            }
 //             isUserChanged[position] = false;
        }
    });

    viewHolder.radioGroup.setOnClickListener(new OnClickListener() 
    {
        public void onClick(View view) 
        {
 //             isUserChanged[position] = true;
        }
    }); 

    viewHolder.itemName.setText(orderList.get(position).getDishName());
    viewHolder.itemQuantity.setText(orderList.get(position).getDishQuantity());

    // change selection state for item checked when selection for radioButton changes
    if(isChecked[position])
        viewHolder.radioGroup.check(R.id.radiobutton_served);
    else
        viewHolder.radioGroup.check(R.id.radiobutton_pending);

    return convertView;
}
  • 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-08T11:31:54+00:00Added an answer on June 8, 2026 at 11:31 am

    I think I got it. Whenever you scroll, you change the values or your radiobuttons with your

    if(isChecked[position])
        viewHolder.radioGroup.check(R.id.radiobutton_served);
    else
        viewHolder.radioGroup.check(R.id.radiobutton_pending);
    

    But you set a listener BEFORE you call that. So the listener is called each time.

    Try this instead:

    viewHolder.radioGroup.setOnCheckedChangeListener(null);
    
    if(isChecked[position])
        viewHolder.radioGroup.check(R.id.radiobutton_served);
    else
        viewHolder.radioGroup.check(R.id.radiobutton_pending);
    
    viewHolder.radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() 
        {           
            public void onCheckedChanged(RadioGroup group, int checkedId) 
            {
     //             if(isUserChanged[position])
                {
                    switch(checkedId) 
                    {
                        case R.id.radiobutton_served:
                             System.out.println(" --- radiobutton_served ---"+" position "+position+" isChecked[position] "+isChecked[position]);
                             count--;
     //                          countView.setText(DataHelper.getAppropriateCountValue(count));
                             isChecked[position] = true;
                             break;
    
                        case R.id.radiobutton_pending:
                             System.out.println(" --- radiobutton_pending ---"+" position "+position+" isChecked[position] "+isChecked[position]);
                             isChecked[position] = false;
                             count++;
     //                          countView.setText(DataHelper.getAppropriateCountValue(count));
                             break;             
                    }
                    countView.setText(DataHelper.getAppropriateCountValue(count));
    
                }
     //             isUserChanged[position] = false;
            }
        });
    

    Hope this will help you.

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

Sidebar

Related Questions

I have a Custom ListView with an imageview and 2 TextViews above each other
Suppose multiple Modal Windows shown above each other. All of those have ShowInTaskbar =
I want to achieve was is shown on the picture above. I have a
I have 2 divs above each others, at a given moment one is shown
I want to draw the number badge as shown in the above image on
It is shown that initWithFrame is deprecated with initWithStyle in sdk3.0 and above. But
I want two custom (i.e. subclassed) UIViews in a subclassed UITableViewCell as shown in
I have PreferenceActivity with several PreferenceGroup. The ListView doesn't show a divider above and
i have content i need to display above my listview and below, so much
i am creating custom listview. passing data to the edittext . at that time

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.