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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:43:45+00:00 2026-05-26T02:43:45+00:00

I have a layout for my list row with some text and a layout

  • 0

I have a layout for my list row with some text and a layout which is supposed to emulate a button. The problem I’m facing is I will always get the latest data in the cursor, meaning if I click the layout on row one I should get grp id 1 and grp name ONE, but I’m getting grp id 3, grp name THREE regardless of which layout I click on in the listview. What’s the way to fix this? My code:

In the getView method

ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            holder.text2 = (TextView) vi.findViewById(R.id.text2);
            holder.layout1 = (LinearLayout)vi.findViewById(R.id.info);
            vi.setTag(holder);
        } else {
            holder = (ViewHolder) vi.getTag();
        }

        String grpCount = c.getString(c
                .getColumnIndex(TestDbAdapter.KEY_GRP_COUNT));

        holder.text2.setText("Channels: " + grpCount);

        holder.layout1.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                System.out.println(c.getString(c.getColumnIndex(TestDbAdapter.KEY_GRP_NAME)));
                System.out.println(c.getString(c.getColumnIndex(TestDbAdapter.KEY_GRP_ID)));
            }
        });

        return vi;
  • 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-26T02:43:45+00:00Added an answer on May 26, 2026 at 2:43 am

    Just check it, I think it should get fix like this:

     String grpCount = c.getString(c
                    .getColumnIndex(TestDbAdapter.KEY_GRP_COUNT));
    final String grpName = c.getString(c.getColumnIndex(TestDbAdapter.KEY_GRP_NAME));
    final String grpId = c.getString(c.getColumnIndex(TestDbAdapter.KEY_GRP_ID));
    
            holder.text2.setText("Channels: " + grpCount);
    
            holder.layout1.setOnClickListener(new OnClickListener() {
    
                @Override
                public void onClick(View v) {
                    System.out.println(grpName);
                    System.out.println(grpId);
                }
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a listview with each row containing some text and a delete button.
I have two questions regarding to html table layout. First I will provide some
I have a ListView with some custom layout for the row (an image, then
I have a layout which uses min-width and works great. So I came to
I have a layout that is working, but it has one very annoying problem..
I have a layout in which I am displaying a webview . I want
I have a layout as follows: <div style=width: 300> <div style=width: 300>Some Content</div> </div
I have this layout that works correctly, a relative layout with a text view
I have created a specific List which exists out of the following elements to
I have been having problems creating a relative layout in XML for a list

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.