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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:48:04+00:00 2026-06-17T22:48:04+00:00

What I am doing right now is to pull some data from an API

  • 0

What I am doing right now is to pull some data from an API and for each item in the response, I inflate the layout and add another item to the layout.

What I want is to have an “add to favorites” button, which will add the current item in an SQLite database. I’ve already created the DAO stuff and the DB handling, but there’s one thing that bugs me.

When I click the button, I can’t tell which item ID’s button has been clicked. I’m normally a web developer and on the web, a button can have data-xxx="yyy" attributes, where xxx and yyy are what ever the developer wants.

Is this possible in Android? I have another solution, but it’s more like a “hack”: create a hidden TextView that holds my item’s ID, and get the onClick event to check that TextView (the one that is a sibling to the button). Any other ideas?

  • 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-06-17T22:48:05+00:00Added an answer on June 17, 2026 at 10:48 pm

    When I click the button, I can’t tell which item ID’s button has been
    clicked

    You can add a piece of arbitrary data to any View by using the setTag() method. When you inflate the layout for a new item, get the id of that item and set it as the tag for the Button in the newly inflated layout corresponding to that item. You’ll be able then, in the OnClickListener for the Button, to retrieve the tag(the id in your case) with the getTag() method and happily insert it in the database.

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

Sidebar

Related Questions

Right now I'm doing this: SELECT * FROM messages WHERE location_id = 7 AND
I am coming from Java and try to learn Javascript right now. Doing that
I'm doing some research on how to pull information from a MySQL DB to
I know I can accomplish it with custom components (I'm doing it right now
Right now I'm doing as follow: uint8_t ManualFlow = 40; // 0 -> 255
I have a problem here. Right now I'm doing my Web Based Application, my
What is the most efficient way to do this? Right now I am doing
I'd like to darken a UIView by a certain amount. Right now, I'm doing
I know you can’t add a class called Socket in VS2010 by doing: Right
Right now I use a PHP script to pull together multiple CSS files into

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.