Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to pass image and text in list view to another activity
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/8407336/how-to-pass-drawable-between-activities">How to pass drawable between activities</a> </p> </blockquote> <p>I want to pass the image and text in this listview to another activity. Can someone explain to me how to pass image and text to another activity which displays both image and text</p> <p>In the code there are two activities home activity and list_display in this list_display class created custom listview with image and text and I got the listview with image and text now I want to pass image and text to third activity which displays both image and text</p> <p>Home Activity</p> <pre><code> public void onClick(View v) { // TODO Auto-generated method stub if(v.getId()==R.id.iv_animals) { Intent intent=new Intent(Home_Activity.this,List_Display.class); intent.putExtra("type", "animal"); startActivity(intent); }else if(v.getId()==R.id.iv_wild) { Intent intent=new Intent(Home_Activity.this,List_Display.class); intent.putExtra("type", "wild"); startActivity(intent); } package com.myown.kidszoo; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.BaseAdapter; import android.widget.GridView; import android.widget.ImageView; import android.widget.ListView; import android.widget.SimpleAdapter; import android.widget.TextView; public class List_Display extends Activity implements OnItemClickListener { Object animalArray[][]={{"animal",R.drawable.a_american_alligator,"ALIGATOR"},"animal",R.drawable.bear,"BEAR"}, {"animal",R.drawable.camel,"CAMEL"},{"animal",R.drawable.dog,"DOG"}, {"wild",R.drawable.elephant,"ELEPHANT"},{"wild",R.drawable.fox,"FOX"}, {"wild",R.drawable.giraffe,"GIRAFFE"},{"wild",R.drawable.hippopotamus,"HIPPOPOTAMUS"}, String i; int lstIndex; int pos; public Context mContext; @Override public void onCreate(Bundle instance) { super.onCreate(instance); setContentView(R.layout.list_sample); i=getIntent().getExtras().getString("type"); List&lt;HashMap&lt;String,Object&gt;&gt; nameList=new ArrayList&lt;HashMap&lt;String,Object&gt;&gt;(); HashMap&lt;String,Object&gt; hm=new HashMap&lt;String, Object&gt;(); if(i.equals("animal")) { for(int i=0;i&lt;animalArray.length;i++) { hm.put("name", animalArray[i][1]); hm.put("image", animalArray[i][2]); nameList.add(hm); }} if(i.equals("wild")) { for(int i=0;i&lt;animalArray.length;i++) { hm.put("name", animalArray[i][1]); hm.put("image", animalArray[i][2]); nameList.add(hm); }} ListView lv1=(ListView)findViewById(R.id.ListView1); String from[]={"image","name"}; int to[]={R.id.iv_home_singlelist,R.id.tv_name_single}; SimpleAdapter adapter=new SimpleAdapter(getApplicationContext(), nameList, R.layout.single_list, from, to); lv1.setAdapter(adapter); lv1.setOnItemClickListener(this); } public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int position, long arg3) { // TODO Auto-generated method stub Intent intent=new Intent(List_Display.this,Fullimage_Display.class); // // what data i need to give here to go to next activity startActivity(intent); }; } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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