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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:25:11+00:00 2026-05-16T11:25:11+00:00

I have a view that has a custom ArrayAdapter as a ListAdapter. Customer is

  • 0

I have a view that has a custom ArrayAdapter as a ListAdapter.
Customer is a Poco:

public class Customer {
    public String LastName;
    public boolean IsActive;
}

What works: I have sucesfully bound my ArrayList to my ListView, the LastName is displayed as a text and the CheckBox is checked or not (depending on IsActive) but now I want to update the ArrayList everytime the checkbox is checked but I can’t access the position in the OnClickListener:

setListAdapter(new ArrayAdapter<Customer>(this, android.R.layout.simple_list_item_checked, items) {

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        View row;
        if (null == convertView) {
            row =  mInflater.inflate(android.R.layout.simple_list_item_checked, null);
        } else {
            row = convertView;
        }

        CheckedTextView ctv = (CheckedTextView) row.findViewById(android.R.id.text1);
        ctv.setText(getItem(position).LastName);
        ctv.setChecked(getItem(position).IsChecked);

        ctv.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                CheckedTextView ctv = (CheckedTextView) v;
                ctv.toggle();

                // this does not work because I don't have the position
                getItem(position).IsChecked = (ctv).isChecked();

            }

        });

        return row;
    }

});

I thought about inheriting from CheckedTextBox and adding a custom property setPosition/getPosition to store the position for later use or even add a reference to the related object but I suppose there is an existing solution I can’t find atm.

  • 1 1 Answer
  • 2 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-16T11:25:12+00:00Added an answer on May 16, 2026 at 11:25 am

    I would handle the click not by the row, but by the ListActivity

    public void onListItemClick(ListView l, View v, int position, long id)
    

    that gives you everything you need. Override the method in your ListActivity.

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

Sidebar

Related Questions

I have a custom view, that has page and block. But the problem when
So I have this page that has some basic custom tabs: http://demo.unlockedmanagement.com/users/view/2 * NOTE
I have never seen this before. I have a simple custom view that has
I have a universal iOS app with a custom view that has three buttons,
I have a table view that has custom cells. In every cell I have
I have a custom view controller that has a view on the bottom half.
I have a custom view that has to track the user's location. I put
I have an Activity that inflates an XML FrameLayout that has a custom View,
I have a View that has a UIWebView, and an OptionsPane (Custom UIViewController with
I have a custom ArrayAdapter I use to manage my ListView: public class FilesAdapter

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.