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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:58:31+00:00 2026-05-20T17:58:31+00:00

Before I added a button to the layout XML for my rows, the row

  • 0

Before I added a button to the layout XML for my rows, the row ID was returned in the callback onListItemClick() upon a list item being clicked. Now that I added a button to the list row layout, this callback doesn’t work anymore. I read that this is normal. I have been able to get the text and the new button to refer to new callbacks via the inclusion of this sort of thing in the layout XML file for my list row:

<Button
    android:onClick="newCallBackFunctionName"/>

The problem is that I can’t seem to find a way to retrieve the row id number corresponding to the list item in which the particular button that was pressed lies. In the case of onListItemClick() this was passed as part of the callback, but in the above case only the View object that is clicked is passed back to the callback newCallBackFunctionName. What can I do about this?

*Edit: My list is populated by a SimpleCursorAdaptor, in case that’s important.

*Edit: My list and list row XML layouts are as follows:

List:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/basic_linear_layout_v1">

<TextView 
    android:id="@+id/category_selection_page_name"
    style="@style/page_heading_v1"/>

<ListView
    android:id="@id/android:list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:drawSelectorOnTop="false"/>

<TextView
    android:id="@id/android:empty"
    style="@style/problem_text_v1"
    android:text="@string/search_list_empty" />

<Button
    android:id="@+id/select_category_button"
    android:textSize="20sp"
    android:layout_weight="10"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:onClick="reload"/>

Row:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView android:id="@+id/category_browse_name" style="@style/basic_list_item_v1"
    android:layout_weight="1"
    android:layout_gravity="left"
    android:focusable="true"
    android:clickable="true"/>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_gravity="right">
    <Button 
        android:text="..." 
        android:id="@+id/subcategories_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:focusable="true"
        android:onClick="onSubcategoryButtonClick">
    </Button>
</LinearLayout>

  • 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-20T17:58:31+00:00Added an answer on May 20, 2026 at 5:58 pm

    You can tag your Buttons with the appropriate id or position in your adapter’s getView method. For example:

    myButton.setTag(id);
    

    Then in your onClick handler, retrieve the tag from the view that was clicked. For example:

    public void newCallBackFunctionName(View v) {
        long id = (Long) v.getTag();
        // ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have a dynamic table, with rows added over time as a
I've added some buttons to my app with a background image (RESET button below),
Before you answer this I have never developed anything popular enough to attain high
Before I start, I know there is this post and it doesn't answer my
Before I do this I figured I would ask if it was the best
Before I jump headlong into C#... I've always felt that C, or maybe C++,
Before, I have found the Cost in the execution plan to be a good
Before moving on to use SVN, I used to manage my project by simply
Before anyone suggests scrapping the table tags altogether, I'm just modifying this part of
Before I upgraded to Firefox 3 I used to constantly use the View Source

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.