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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:14:34+00:00 2026-06-01T13:14:34+00:00

I’ve had a look around, and it might be because I’m not sure what

  • 0

I’ve had a look around, and it might be because I’m not sure what I’m looking for, but I can’t find out how to do something I presume should be quite easy with android.

I have an array of data to display on the screen. This data is a class that holds a database key, name and image.

I’m currently displaying this data as an ImageView and a TextView. I loop through the array and add a new row to a TableLayout containing the image and text.

I’d like both the image and text to be clickable, changing to a new activity.

This new activity needs to know the database key of the row clicked in order to display the correct data.

Here’s what I have so far:

private void fillSuggestionTable(TableLayout tabSuggestions, Suggestion[] arrToAdd)
{
    for(int i = 0; i < arrToAdd.length; i++)
    {
        /* Create a new row to be added. */
        TableRow trSuggestion = new TableRow(this);
        trSuggestion.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));

        /* Create objects for the row-content. */
        ImageView imgDisplayPicture = new ImageView(this);
        ImageHandler.loadBitmap(arrToAdd[i].strImageURL, imgDisplayPicture);
        imgDisplayPicture.setLayoutParams(new LayoutParams(50,50));

        TextView txtArtistName = new TextView(this);
        txtArtistName.setText(arrToAdd[i].strName);
        txtArtistName.setTextColor(Color.parseColor("#000000"));

        /* Add data to row. */
        trSuggestion.addView(imgDisplayPicture);
        trSuggestion.addView(txtArtistName);

        /* Add row to TableLayout. */
        tabSuggestions.addView(trSuggestion, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    }
}
  • 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-01T13:14:36+00:00Added an answer on June 1, 2026 at 1:14 pm

    Is there a reason you’re using a TableView? it seems like what you want to accomplish would be much easier with a ListView & custom CursorAdapter, where the adapter can handle translating from the database to the ListView row. At that point starting a new activity that knows the database ID is trivial:

    mListView.setOnItemClickListener(new OnItemClickListener() {
      @Override
      public void onItemClick (AdapterView<?> parent, View view, int position, long id) {
        Intent i = new Intent(MyActivity.this, MyOtherActivity.class);
        i.putExtra("database_id", id);
        startActivity(i);
      }
    });
    

    And in MyOtherActivity:

    private int dbId;
    protected void onCreate(Bundle savedInstanceState) {
      //do stuff
      dbId = getIntent().getIntExtra("database_id", -1); // the -1 is the default if the extra can't be found
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
Seemingly simple, but I cannot find anything relevant on the web. What is the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.