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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:07:59+00:00 2026-06-02T02:07:59+00:00

I am working on a customized list view here is my adapter class public

  • 0

I am working on a customized list view

this is my apps screen shot

here is my adapter class

public class MenubaseAdapter extends BaseAdapter {
private static ArrayList<MenuItem> searchMenuItemArraylist;
private LayoutInflater menuInflater;
public MenubaseAdapter( Context context,ArrayList<MenuItem> results) {
    searchMenuItemArraylist=results;
    menuInflater = LayoutInflater.from(context);
}

@Override
public int getCount() {
    // TODO Auto-generated method stub
    return searchMenuItemArraylist.size();
}

@Override
public Object getItem(int position) {
    // TODO Auto-generated method stub
    return position;
}

@Override
public long getItemId(int position) {
    // TODO Auto-generated method stub
    return position;
}

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub

               iewHolder holder;
            if(convertView==null)
            {
                convertView=menuInflater.inflate(R.layout.menu_list, null);
                holder=new MenuViewHolder();

                holder.txtItemName=(TextView)convertView.findViewById(R.id.textView_menuitem);
                holder.txtItemPrice=(TextView)convertView.findViewById(R.id.textView_itemprice);
                holder.txtItemQty=(TextView)convertView.findViewById(R.id.TextView_itemQty);
                holder.selectChk=(CheckBox)convertView.findViewById(R.id.checkBox_menuchk);



                convertView.setTag(holder);
            }else {
                holder=(MenuViewHolder)convertView.getTag();
            }
            holder.txtItemName.setText(searchMenuItemArraylist.get(position).getMenuItemname());
            holder.txtItemPrice.setText(searchMenuItemArraylist.get(position).getMenuItemPrice());
            holder.txtItemQty.setText(searchMenuItemArraylist.get(position).getItemQty());
            holder.selectChk.setChecked(searchMenuItemArraylist.get(position).isSelected());
holder.selectChk.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        // TODO Auto-generated method stub

                        //how to select the listview item ?
                    }
                });

 return convertView;

        }

static class MenuViewHolder
{
    TextView txtItemName;
    TextView txtItemPrice;
    TextView txtItemQty;
    CheckBox selectChk;
}

}

Now my problem is when I am clicking on the foodmenuitems the list get selected and the check box get checked.but if I only click on the checkbox then the list item won’t get selected.thnx in advance.

  • 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-02T02:08:00+00:00Added an answer on June 2, 2026 at 2:08 am

    To keep the track of the selected items, take one temporary arraylist of your object or simple arraylist of string in which you will add or remove the selected items.

    For example

    You have one temporary arraylist ArrayList<MenuItem> tempList;

    Now in getview method you will have to do two changes

    1. Check weather the current object is in the temp arraylist or not. If the current element is in the temp array list then just set the status of the checkbox to true else set it to false.
    2. In the onClick method of the checkbox first check the status of the checkbox. If the checkbox is checked then just check weather the current element is in the temp arraylist or not if not then just add the current element in the arraylist. if the status of the checkbox is unchecked then check in the temp arraylist for current element and if exists in the temp arraylist then remove it from the list and after that call the notifyDatasetChanged method
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a nicely working custom CursorAdapter with customized ListView. This view allows the
I have customized the UIAlertView class. It's working perfectly. I don't want the bounce
I am working on customize (inflated) list view. In which I have used the
I am having a customized list view in my application, which is showing an
Working on my first Android app here. I've searched and tried everything I can
I am working on a model criteria builder. I have a dropdown list with
I already have a production instance deployed on the server. Its working well. Here
I am working on a customized rich text editor and I am wondering if
I am working on a win 32 sample. In that I am using List
I am working on a project that is a customized and specific CMS. In

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.