Note that there are some explanatory texts on larger screens.

plurals
  1. POClicking on the listview it has to go their respective activity?
    primarykey
    data
    text
    <p>I have one <code>ListView</code>. It contains text with images. I know that if I click the <code>ListView</code> item a <code>Toast</code> will appear, but what I want is for a click on the item to open their respective activity.</p> <pre><code> @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(SouthIndian.this, "You have chosen : " + " " + obj_itemDetails.getName(), Toast.LENGTH_LONG).show(); switch(obj_itemDetails.getName()) { case "Vegterian": Intent newActivity = new Intent(SouthIndian.this, SouthIndianvegrecipes.class); startActivity(newActivity); break; case "Non-Vegterian": Intent new1Activity = new Intent(SouthIndian.this, SouthIndiannonvegrecipes.class); startActivity(new1Activity); break; //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("Vegterian"); item_details.setItemDescription("Recipes made by raw materials"); //item_details.setPrice("RS 310.00"); item_details.setImageNumber(1); results.add(item_details); item_details = new Recipedetails(); item_details.setName("Non-Vegterian"); item_details.setItemDescription("Flesh of sweet animals"); //item_details.setPrice("RS 350.00"); item_details.setImageNumber(2); results.add(item_details); item_details = new Recipedetails(); item_details.setName("Pickels"); item_details.setItemDescription("Touchable dish by Homemade"); //item_details.setPrice("RS 250.00"); item_details.setImageNumber(3); results.add(item_details); item_details = new Recipedetails(); item_details.setName("Soups"); item_details.setItemDescription("Startup for our food"); //item_details.setPrice("RS 350.00"); item_details.setImageNumber(4); results.add(item_details); return results; } </code></pre> <p>What I want is if I click the first image it has to go their <code>Activity</code>. Like that it has to go their respective activity, not a same one. How can I do this?</p> <p>My AndroidManifest.xml</p> <pre><code> &lt;activity android:name="com.example.recipestutors.MainActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name="RecipeActivity" android:label="@string/activity_recipeview" android:theme="@style/AppTheme"&gt;&lt;/activity&gt; &lt;activity android:name="SouthIndian" android:label="@string/activity_SouthIndianrecipeview" android:theme="@style/AppTheme"&gt;&lt;/activity&gt; &lt;activity android:name="NorthIndian" android:label="@string/activity_NorthIndianrecipeview" android:theme="@style/AppTheme"&gt;&lt;/activity&gt; &lt;activity android:name="Western" android:label="@string/activity_Westernrecipeview" android:theme="@style/AppTheme"&gt;&lt;/activity&gt; &lt;activity android:name="Chinese" android:label="@string/activity_Chineserecipeview" android:theme="@style/AppTheme"&gt;&lt;/activity&gt; &lt;activity android:name="SouthIndianvegrecipes" android:label="@string/activity_Chineserecipeview" android:theme="@style/AppTheme"&gt;&lt;/activity&gt; &lt;activity android:name="SouthIndiannonvegrecipes" android:label="@string/activity_Chineserecipeview" android:theme="@style/AppTheme"&gt;&lt;/activity&gt; &lt;/application&gt; </code></pre> <p>logcat showing error</p> <pre><code> 03-05 10:47:36.091: E/AndroidRuntime(3485): FATAL EXCEPTION: main 03-05 10:47:36.091: E/AndroidRuntime(3485): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.recipestutors/com.example.recipestutors.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.recipestutors.MainActivity" on path: /data/app/com.example.recipestutors-1.apk 03-05 10:47:36.091: E/AndroidRuntime(3485): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106) 03-05 10:47:36.091: E/AndroidRuntime(3485): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 03-05 10:47:36.091: E/AndroidRuntime(3485): at android.app.ActivityThread.access$600(ActivityThread.java:141) 03-05 10:47:36.091: E/AndroidRuntime(3485): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 03-05 10:47:36.091: E/AndroidRuntime(3485): at android.os.Handler.dispatchMessage(Handler.java:99) 03-05 10:47:36.091: E/AndroidRuntime(3485): at android.os.Looper.loop(Looper.java:137) 03-05 10:47:36.091: E/AndroidRuntime(3485): at android.app.ActivityThread.main(ActivityThread.java:5039) 03-05 10:47:36.091: E/AndroidRuntime(3485): at java.lang.reflect.Method.invokeNative(Native Method) 03-05 10:47:36.091: E/AndroidRuntime(3485): at java.lang.reflect.Method.invoke(Method.java:511) 03-05 10:47:36.091: E/AndroidRuntime(3485): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 03-05 10:47:36.091: E/AndroidRuntime(3485): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 03-05 10:47:36.091: E/AndroidRuntime(3485): at dalvik.system.NativeStart.main(Native Method) 03-05 10:47:36.091: E/AndroidRuntime(3485): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.recipestutors.MainActivity" on path: /data/app/com.example.recipestutors-1.apk 03-05 10:47:36.091: E/AndroidRuntime(3485): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65) 03-05 10:47:36.091: E/AndroidRuntime(3485): at java.lang.ClassLoader.loadClass(ClassLoader.java:501) 03-05 10:47:36.091: E/AndroidRuntime(3485): at java.lang.ClassLoader.loadClass(ClassLoader.java:461) 03-05 10:47:36.091: E/AndroidRuntime(3485): at android.app.Instrumentation.newActivity(Instrumentation.java:1054) 03-05 10:47:36.091: E/AndroidRuntime(3485): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097) 03-05 10:47:36.091: E/AndroidRuntime(3485): ... 11 more </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.
    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