Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In your <code>LatestTab</code></p> <p>Declare the list as a class member</p> <pre><code> List&lt;Item&gt; items = new ArrayList&lt;Item&gt;(); </code></pre> <p>Add the items to the list</p> <pre><code>items.add(new Item("One", R.drawable.abstact_one)); items.add(new Item("Two", R.drawable.abstract_three)); items.add(new Item("Three", R.drawable.image_two)); items.add(new Item("Four", R.drawable.image_four)); items.add(new Item("Five", R.drawable.image_five)); items.add(new Item("Six", R.drawable.image_nine)); items.add(new Item("Seven", R.drawable.image_ten)); </code></pre> <p>Your Item class</p> <pre><code>public class Item { String name; int drawable; public int getDrawable() { return drawable; } public void setDrawable(int drawable) { this.drawable = drawable; } public Item(String name, int id) { this.name= name; this.drawable = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } } </code></pre> <p>Pass the list to the constructor of adapter class</p> <pre><code> gridView.setAdapter(new ImageAdapter(this,items)); </code></pre> <p>In the constructor</p> <pre><code> List&lt;Item&gt; items; public ImageAdapter(Context context,List&lt;Item&gt; items) { inflater = LayoutInflater.from(context); this.items = items; } </code></pre> <p>then in getVIew</p> <pre><code> Item item = (Item)items.get(i); picture.setImageResource(item.getDrawable()); </code></pre> <p>Then in item click listener</p> <pre><code> Item item = items.get(position); int id = item.getDrawable(); Intent i = new Intent(getApplicationContext(), FullImageActivity.class); i.putExtra("idkey", id); // pass the id startActivity(i); </code></pre> <p>Then in FullImageActivity</p> <pre><code> int id = getIntent().getIntExtra("idkey"); //get id imageview.setImageResource(id); // set the drawable to imageview </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.
 

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