Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to change the content of listview according to the clicked item?
    text
    copied!<p>Having an listview,if i clicked an item in the listview it has to go to the same activity for all item clicking in an list view,what i need is the same activity has to display the contents as different one according to their respective click item. I am having doubt in that activity how to create that one for respective clicking and fetches their data</p> <pre><code> public class SouthIndianvegrecipes1 extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ArrayList&lt;Recipedetails&gt; image_details = GetSearchResults(); final ListView lv1 = (ListView) findViewById(R.id.listV_main); lv1.setAdapter(new ItemListBaseAdapter(this, image_details)); lv1.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; a, View v, int position, long id) { Object o = lv1.getItemAtPosition(position); Recipedetails obj_itemDetails = (Recipedetails)o; Toast.makeText(SouthIndianvegrecipes1.this, "You have chosen : " + " " + obj_itemDetails.getName(), Toast.LENGTH_LONG).show(); Intent newActivity = new Intent(SouthIndianvegrecipes1.this, SouthIndianvegmanualrecipes.class); startActivity(newActivity); /*switch(obj_itemDetails.getImageNumber()) { case 1: Intent newActivity = new Intent(SouthIndianvegrecipes1.this, SouthIndianvegrecipes.class); startActivity(newActivity); break; case 2: Intent new1Activity = new Intent(SouthIndianvegrecipes1.this, SouthIndiannonvegrecipes.class); startActivity(new1Activity); break; case 3: Intent new2Activity = new Intent(SouthIndianvegrecipes1.this, SouthIndianpickelsrecipes.class); startActivity(new2Activity); break; case 4: Intent new3Activity = new Intent(SouthIndianvegrecipes1.this, SouthIndiansoupsrecipes.class); startActivity(new3Activity); break; default: Toast.makeText(SouthIndianvegrecipes1.this, "Wrong Input", Toast.LENGTH_LONG).show(); }*/ /*if(obj_itemDetails.getName().equals("Vegeterain")) { Intent newActivity = new Intent(SouthIndian.this, SouthIndianvegrecipes.class); startActivity(newActivity); } else { Intent new1Activity = new Intent(SouthIndian.this, SouthIndiannonvegrecipes.class); startActivity(new1Activity); //same for other Activity } */ } }); } private ArrayList&lt;Recipedetails&gt; GetSearchResults(){ ArrayList&lt;Recipedetails&gt; results = new ArrayList&lt;Recipedetails&gt;(); Recipedetails item_details = new Recipedetails(); item_details.setName("Godhumai veg adai"); item_details.setItemDescription("This is very good for dibets people"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(12); results.add(item_details); item_details = new Recipedetails(); item_details.setName("Soyamore koozh"); item_details.setItemDescription("Tasty to have this as main dish"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(13); results.add(item_details); item_details = new Recipedetails(); item_details.setName("Tomato kulambu"); item_details.setItemDescription("Good side dish for rice and dinner"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(14); results.add(item_details); item_details = new Recipedetails(); item_details.setName("Tomato upma"); item_details.setItemDescription("Evening time dinner for kids"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(15); results.add(item_details); item_details = new Recipedetails(); item_details.setName("Tomato upma"); item_details.setItemDescription("Evening time dinner for kids"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(15); results.add(item_details); item_details = new Recipedetails(); item_details.setName("Navratri special vada"); item_details.setItemDescription("Good snacks at the function"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(16); results.add(item_details); item_details = new Recipedetails(); item_details.setName("Egg kurma"); item_details.setItemDescription("Wonderful dish made by egg"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(17); results.add(item_details); item_details = new Recipedetails(); item_details.setName("Milagu kuzhambu"); item_details.setItemDescription("Good for digestion purpose"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(18); results.add(item_details); item_details = new Recipedetails(); item_details.setName("Rasam"); item_details.setItemDescription("Last and famous dish in lunch,good for health also"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(19); results.add(item_details); item_details = new Recipedetails(); item_details.setName("Vegetable kootu"); item_details.setItemDescription("Nice and healthy one"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(20); results.add(item_details); item_details = new Recipedetails(); item_details.setName("Avial"); item_details.setItemDescription("Easy to prepare and lots of vegetable"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(21); results.add(item_details); item_details = new Recipedetails(); item_details.setName("kothavarangaicurry"); item_details.setItemDescription("Tamilnadu special and healthy too"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(22); results.add(item_details); return results; } </code></pre> <p>}this is code,here if i click that item in an listview,it has to go the next activity and where i will write the data for items</p> <pre><code> public class SouthIndianvegmanualrecipes extends Activity { private Object getIntent; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.recipe_manual); ArrayList&lt;Recipedetails2&gt; image_details = GetSearchResults(); final ListView lv1 = (ListView) findViewById(R.id.listV_main); lv1.setAdapter(new ItemListBaseAdapter2(this, image_details)); /* lv1.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; a, View v, int position, long id) { Object o = lv1.getItemAtPosition(position); Recipedetails obj_itemDetails = (Recipedetails)o; Toast.makeText(SouthIndianvegrecipes1.this, "You have chosen : " + " " + obj_itemDetails.getName(), Toast.LENGTH_LONG).show(); Intent newActivity = new Intent(SouthIndianvegrecipes1.this, SouthIndianvegmanualrecipes.class); startActivity(newActivity); /*switch(obj_itemDetails.getImageNumber()) { case 1: Intent newActivity = new Intent(SouthIndianvegrecipes1.this, SouthIndianvegrecipes.class); startActivity(newActivity); break; case 2: Intent new1Activity = new Intent(SouthIndianvegrecipes1.this, SouthIndiannonvegrecipes.class); startActivity(new1Activity); break; case 3: Intent new2Activity = new Intent(SouthIndianvegrecipes1.this, SouthIndianpickelsrecipes.class); startActivity(new2Activity); break; case 4: Intent new3Activity = new Intent(SouthIndianvegrecipes1.this, SouthIndiansoupsrecipes.class); startActivity(new3Activity); break; default: Toast.makeText(SouthIndianvegrecipes1.this, "Wrong Input", Toast.LENGTH_LONG).show(); }*/ /*if(obj_itemDetails.getName().equals("Vegeterain")) { Intent newActivity = new Intent(SouthIndian.this, SouthIndianvegrecipes.class); startActivity(newActivity); } else { Intent new1Activity = new Intent(SouthIndian.this, SouthIndiannonvegrecipes.class); startActivity(new1Activity); //same for other Activity } */ //} //}); } Bundle extras = getIntent().getExtras(); int[] obj_itemDetails.getImageNumber() = extras.getIntArray("numbers"); private ArrayList&lt;Recipedetails2&gt; GetSearchResults(){ ArrayList&lt;Recipedetails2&gt; results = new ArrayList&lt;Recipedetails2&gt;(); Recipedetails2 item_details = new Recipedetails2(); item_details.setName("Godhumai veg adai"); item_details.setIngredients("This is very good for dibets people"); item_details.setMethods("This is very good for dibets people"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(12); results.add(item_details); item_details = new Recipedetails2(); item_details.setName("Soyamore koozh"); item_details.setIngredients("Tasty to have this as main dish"); item_details.setMethods("This is very good for dibets people"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(13); results.add(item_details); item_details = new Recipedetails2(); item_details.setName("Tomato kulambu"); item_details.setIngredients("Good side dish for rice and dinner"); item_details.setMethods("This is very good for dibets people"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(14); results.add(item_details); item_details = new Recipedetails2(); item_details.setName("Tomato upma"); item_details.setIngredients("Evening time dinner for kids"); item_details.setMethods("This is very good for dibets people"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(15); results.add(item_details); item_details = new Recipedetails2(); item_details.setName("Tomato upma"); item_details.setIngredients("Evening time dinner for kids"); item_details.setMethods("This is very good for dibets people"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(15); results.add(item_details); item_details = new Recipedetails2(); item_details.setName("Navratri special vada"); item_details.setIngredients("Good snacks at the function"); item_details.setMethods("This is very good for dibets people"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(16); results.add(item_details); item_details = new Recipedetails2(); item_details.setName("Egg kurma"); item_details.setIngredients("Wonderful dish made by egg"); item_details.setMethods("This is very good for dibets people"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(17); results.add(item_details); item_details = new Recipedetails2(); item_details.setName("Milagu kuzhambu"); item_details.setIngredients("Good for digestion purpose"); item_details.setMethods("This is very good for dibets people"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(18); results.add(item_details); item_details = new Recipedetails2(); item_details.setName("Rasam"); item_details.setIngredients("Last and famous dish in lunch,good for health also"); item_details.setMethods("This is very good for dibets people"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(19); results.add(item_details); item_details = new Recipedetails2(); item_details.setName("Vegetable kootu"); item_details.setIngredients("Nice and healthy one"); item_details.setMethods("This is very good for dibets people"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(20); results.add(item_details); item_details = new Recipedetails2(); item_details.setName("Avial"); item_details.setIngredients("Easy to prepare and lots of vegetable"); item_details.setMethods("This is very good for dibets people"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(21); results.add(item_details); item_details = new Recipedetails2(); item_details.setName("kothavarangaicurry"); item_details.setIngredients("Tamilnadu special and healthy too"); item_details.setMethods("This is very good for dibets people"); //item_details.setUrlWiki("https://www.youtube.com/watch?v=C_r0mFvMSfU"); item_details.setImageNumber(22); results.add(item_details); return results; } } </code></pre> <p>here how i wil write the code for taking the data my xml file,i want to put the code here like respective click</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;ImageView android:id="@+id/itemphoto" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_gravity="top" android:padding="20dp" android:scaleType="center" &gt;&lt;/ImageView&gt; &lt;TextView android:text="Ingredients:" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="left" /&gt; &lt;TextView android:id="@+id/itemIngredients" android:layout_width="wrap_content" android:layout_height="wrap_content" android:scaleType="center" /&gt; &lt;TextView android:text="Method:" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="left" /&gt; &lt;TextView android:id="@+id/methods" android:layout_width="wrap_content" android:layout_height="wrap_content" android:scaleType="center" /&gt; &lt;/LinearLayout&gt; </code></pre>
 

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