Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to switch activity with item specific data sent
    primarykey
    data
    text
    <p>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.</p> <p>I have an array of data to display on the screen. This data is a class that holds a database key, name and image.</p> <p>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.</p> <p>I'd like both the image and text to be clickable, changing to a new activity.</p> <p>This new activity needs to know the database key of the row clicked in order to display the correct data.</p> <p>Here's what I have so far:</p> <pre><code>private void fillSuggestionTable(TableLayout tabSuggestions, Suggestion[] arrToAdd) { for(int i = 0; i &lt; 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)); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload