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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:22:41+00:00 2026-05-16T06:22:41+00:00

I have an activity that extends ListView. I populate my list with the results

  • 0

I have an activity that extends ListView. I populate my list with the results of a query to the sqlite database. A list element consists of start_time, end_time, client_name and status. These are the 4 bits on info I need to display for each list item.

My question is: Is it possible for me to assign hidden elements to this ListView item?

For example, I want to store the _id field of the database row for that ListView item, so that when I click it I can start a new activity based on data for that database row.

EDIT

The Code I use to fill my list from my Cursor:

String[] columns = new String[] {VisitsAdapter.KEY_CLIENT_FULL_NAME, VisitsAdapter.KEY_STATUS,VisitsAdapter.KEY_CLIENT_START_TIME, VisitsAdapter.KEY_CLIENT_END_TIME};

// the XML defined views which the data will be bound to
int[] to = new int[] { R.id.name_entry,R.id.number_entry,R.id.start_time_display,R.id.end_time_display  };

SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(HomeScreen.this, R.layout.list_element, cur, columns, to);

Where R.layout.list_item is the XML for my list item. I come from a PHP/HTML background so what I would typically do here is have a hidden field to hold my _id value that I could then access once the list item was clicked. can I do something similar in android? can I put a hidden _id field in my xml layout?

  • 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-16T06:22:41+00:00Added an answer on May 16, 2026 at 6:22 am

    You should try to loosen yourself from the web development frame of mind a little bit. There is no need to store such a thing as the id in a hidden field in your view. That would mix your data with your user interface and create a lot of confusion and unnecessary view objects.

    If you are using a sqlite database to store your values you should use a CursorAdapter to manager your list items. The CursorAdapter stores the result that you got from the Database and manages how the data is displayed to the user. If you then register an onItemClickListener on your ListView the listener will receive the adapter and the position of the data item whose cell was clicked in the adapter. Now you can use getItem to retrieve a cursor pointing to the database result that was used to create the listitem. Now you can get the id or all other values that are not shown to the user from the database result and attach it to an intent to start the next activity.

    • 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 a custom list adapter (that extends BaseAdapter). My list
I have an activity that extends ViewFactory. The activity does nothing more than act
I have an Android activity that displays a list of log entries (using a
I have an Activity with an AutoCompleteTextView and a ListView with an adapter that
Hi guys I have an activity which extends ListActivity and displays a listview which
I have an activity that extends ListActivity and implementsOnScrollListener: public class RecentItemsList extends GenericListActivity
I have a activity that fills a ListView, and it is working. Because I
I have a class that extends Activity and inflates another xml layout in the
I have a list view populated by an adapter reading from SQLite database. When
I have a listview that is being populated by information from a database using

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.