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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:24:36+00:00 2026-05-24T23:24:36+00:00

i have a checked text view inside of a listview and whenever I click

  • 0

i have a checked text view inside of a listview and whenever I click an item in the list view a random checked text view will check (not neccessarily the one I pressed) Here is my code

lv2.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
            final CheckedTextView checkedTextView = (CheckedTextView) findViewById(R.id.checkedTextView1);

            checkedTextView.toggle();

        }
    });

Where lv2 is my list view and checkedTextView1 is my check view inside each listview item. How do I call a specific checkedTextView. Is there an array format that I can call? eg checkedTextView[1].toggle();?

Edit here is my adapter

public class SpecialAdapter2 extends ArrayAdapter<String> {

private int[] colors = new int[] { R.drawable.row_background_grey,
        R.drawable.row_background_white };

public SpecialAdapter2(Context context, int resource, String[] names) {
    super(context, resource, names);
    // TODO Auto-generated constructor stub
}

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


    View view = super.getView(position, convertView, parent);

    int colorPos = position % colors.length;
    view.setBackgroundResource(colors[colorPos]);
    return view;
}
  • 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-24T23:24:36+00:00Added an answer on May 24, 2026 at 11:24 pm

    Try changing the code in onItemClick() to:

    CheckedTextView checkedTextView = (CheckedTextView)arg1.findViewById(R.id.checkedTextView1);
    checkedTextView.toggle();
    

    The problem is that you are implicitly calling findViewById() on this – ie. your Activity. Invoking findViewById() on your activity will cause it to search through your entire view hierarchy for the first View it can find with the id checkedTextView1. That’s not what you want though – you want to find the specific CheckedTextView in the row item that was clicked. Hence the need to invoke findViewById() on arg1.

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

Sidebar

Related Questions

I have a problem with listview which list item contain a checkbox. When i
A page I have in my app will not display the required text so
I have a ListView, checkboxes = true, View = List. On the start of
I have checked the source codes of ASIHTTPRequest and could not make sure which
I have this fields in a view: Node: Nid Content: text1 Plain text Node:
I have a ListView with an ArrayList adapter. The rows are not very complex
I am trying to delete checked items in my list view my app. The
I have been trying to check if a checkbox is checked for awhile. For
I have a simple jquery click event <script type="text/javascript"> $(function() { $('#post').click(function() { alert("test");
I have an Android ListView with rows that include one checkbox, and four text

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.