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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:40:51+00:00 2026-05-30T10:40:51+00:00

I have a listview with each row having a checkbox, imageview and text view

  • 0

I have a listview with each row having a checkbox, imageview and text view

my requirements are
1. checkbox can be checkd and unchecked and for each click on checkbox for each row do function1 : This i could do by defining an onitem clicklistenr for the check box within the getview of the baseadapter

  1. If any other item than check box is clicked i want to interpret this as a row click and do function 2. Currently i defined an onitemclick listener for the textview and it works

So my question is is that the right way to do it, define onitemclick listener for all other items and make it call function 2 ?

Or is there a way i can achieve the row selection for my list.
Please see my code below . I can give any further details if needed

list.java

public class ScanListActivity extends BaseActivity {
static Button scanlist;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.scan_list);
    List<ScannedProduct> productList = new ArrayList<ScannedProduct>();
    productList = getProductList();
    final ListView lv = (ListView) findViewById(R.id.list);
    scanlist = (Button) findViewById(R.id.addtowishlist);
    scanlist.setEnabled(false);
    lv.setAdapter(new ProductListAdapter(this, productList, scanlist));
}

adapter ;getview

public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    final int pos = position;
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.product_list_row, null);
        holder = new ViewHolder();
        holder.text1 = (TextView) convertView.findViewById(R.id.productid);
        holder.text1.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                Log.i("List",""+pos);

            }
        });
        holder.text2 = (TextView) convertView.findViewById(R.id.price);
        holder.image = (ImageView) convertView
                .findViewById(R.id.productimageid);
        convertView.setTag(holder);
    } else {

        holder = (ViewHolder) convertView.getTag();
    }

    holder.text1.setText(productList.get(position).getTitle());
    holder.text2.setText(productList.get(position).getPrice().toString());
    if(productList.get(position).getSmallImage() != null){
    byte [] bb= (productList.get(position).getSmallImage());
    holder.image.setImageBitmap(BitmapFactory.decodeByteArray(bb, 0, bb.length));
    }
    else{
        holder.image.setImageBitmap(null);
        holder.image.setBackgroundResource(R.drawable.highlight_disabled);
    }



//  holder.image.setImageBitmap(Utils.loadBitmap(productList.get(position).getSmallImage()));
    final CheckBox check = (CheckBox) convertView
            .findViewById(R.id.checkbox);
    check.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        public void onCheckedChanged(CompoundButton buttonView,
                boolean isChecked) {
            if (check.isChecked()) {

                ProductListAdapter.count++;
            } else {
                ProductListAdapter.count--;
            }
            if (ProductListAdapter.count == 0) {
                //showOrHideButton.setClickable(false);
                //showOrHideButton.setVisibility(View.GONE);
                showOrHideButton.setEnabled(false);
            } else {
                //showOrHideButton.setVisibility(View.VISIBLE);
                showOrHideButton.setEnabled(true);
            }

        }
    });
    return convertView;
}

static class ViewHolder {
    TextView text1;
    ImageView image;
    TextView text2;
}
  • 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-30T10:40:53+00:00Added an answer on May 30, 2026 at 10:40 am

    There are 2 options :

    • as you do : define a OnClickListener for each view. But then note that all items could share the same listener (thus declared as a field and not inlined as you did), this would use less memory.

    • use a OnItemClickListener

    The second one is more practical but I remember there is a limitation using it but can’t remember what it was. I personnaly use the first strategy.

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

Sidebar

Related Questions

I have a a listview with each row having a text field and edittext
I have a list view with text and button in each row, list view
I have a ListView with a pretty standard view for each row - an
I have a listview with each row containing some text and a delete button.
I have a ListView with some text, each row contains different length text and
I have seen examples of ListView where each row has multiple view objects, like
I have created listview using layoutinflator. Listview contains checkbox and textview for each row.
I want to have a list view with each row having two buttons like
I have a listView, where each row has a button in the row layout.
I have an app using a ListView as a main screen. Each row displays

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.