i have face this error,i cant found the solution please help.Application is based on listview Activity.when u click on one listview item then it ll go to another listview.second activity start but ther is some error please help yr...this error ...... --------------------------------------------------------------------------------------------------------------------------------------------------------------------
07-27 15:38:48.117: WARN/dalvikvm(741): threadid=3: thread exiting with uncaught exception (group=0x4000fe70) 07-27 15:38:48.127: ERROR/AndroidRuntime(741): Uncaught handler: thread main exiting due to uncaught exception 07-27 15:38:48.147: ERROR/AndroidRuntime(741): java.lang.RuntimeException: Unable to stop activity {com.vigyaapan.Exercise/com.vigyaapan.Exercise.GymExercise}: java.lang.NullPointerException 07-27 15:38:48.147: ERROR/AndroidRuntime(741): at android.app.ActivityThread.performStopActivityInner (ActivityThread.java:2905) 07-27 15:38:48.147: ERROR/AndroidRuntime(741): at android.app.ActivityThread.handleStopActivity(ActivityThread.java: 2948) 07-27 15:38:48.147: ERROR/AndroidRuntime(741): at android.app.ActivityThread.access$2100(ActivityThread.java:112) 07-27 15:38:48.147: ERROR/AndroidRuntime(741): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1708) 07-27 15:38:48.147: ERROR/AndroidRuntime(741): at android.os.Handler.dispatchMessage(Handler.java:99) 07-27 15:38:48.147: ERROR/AndroidRuntime(741): at android.os.Looper.loop(Looper.java:123) 07-27 15:38:48.147: ERROR/AndroidRuntime(741): at android.app.ActivityThread.main(ActivityThread.java:3948) 07-27 15:38:48.147: ERROR/AndroidRuntime(741): at java.lang.reflect.Method.invokeNative(Native Method) 07-27 15:38:48.147: ERROR/AndroidRuntime(741): at java.lang.reflect.Method.invoke(Method.java:521) 07-27 15:38:48.147: ERROR/AndroidRuntime(741): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:782) 07-27 15:38:48.147: ERROR/AndroidRuntime(741): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540) 07-27 15:38:48.147: ERROR/AndroidRuntime(741): at dalvik.system.NativeStart.main(Native Method) 07-27 15:38:48.147: ERROR/AndroidRuntime(741): Caused by: java.lang.NullPointerException 07-27 15:38:48.147: ERROR/AndroidRuntime(741): at android.app.Activity.performStop(Activity.java:3575) 07-27 15:38:48.147: ERROR/AndroidRuntime(741): at android.app.ActivityThread.performStopActivityInner (ActivityThread.java:2902) 07-27 15:38:48.147: ERROR/AndroidRuntime(741): ... 11 more ------------------------------------------------------------------------------------------------------------------------------------------------ here is my program ------------------------------------------- package com.vigyaapan.Exercise; import android.app.ListActivity; import android.content.Intent; import android.database.Cursor; import android.os.Bundle; import android.util.AndroidRuntimeException; import android.view.View; import android.widget.ArrayAdapter; import android.widget.ListView; public class GymExercise extends ListActivity { DBExercise dbExercise = new DBExercise(this); Cursor cursor; String aryListMainMenu[]; int intGetSelectedItem = 0; protected ListView lv; public void onCreate(Bundle savedInstanceState) { try { super.onCreate(savedInstanceState); dbExercise.openDataBase(); dbExercise.getTricepDipImage(); aryListMainMenu = dbExercise.displayMainMenu(); startManagingCursor(cursor); if(dbExercise != null) dbExercise.close(); setContentView(R.layout.main); lv = (ListView)this.findViewById(android.R.id.list); setupListView(); } catch(NullPointerException e) { e.printStackTrace(); } } private void setupListView() { try { ArrayAdapter listItemAdapter = new ArrayAdapter (this,android.R.layout.simple_list_item_1,aryListMainMenu); lv.setAdapter(listItemAdapter); } catch(AndroidRuntimeException e) { e.printStackTrace(); } } @Override protected void onListItemClick(ListView l, View v, int position, long id) { try { super.onListItemClick(l, v, position, id); if(position == 0) { Intent intentShoulder = new Intent (GymExercise.this,ShoulderViewController.class); startActivity(intentShoulder); lv.bringToFront(); } if(position == 1) { Intent intentTriceps = new Intent (GymExercise.this,TricepsViewController.class); startActivity(intentTriceps); } if(position == 2) { Intent intentBiceps = new Intent (GymExercise.this,BicepsViewController.class); startActivity(intentBiceps); } if(position == 3) { Intent intentChest = new Intent (GymExercise.this,ChestViewController.class); startActivity(intentChest); } if(position == 4) { Intent intentBackView = new Intent (GymExercise.this,BackViewController.class); startActivity(intentBackView); } if(position == 5) { Intent intentLeg = new Intent (GymExercise.this,LegViewController.class); startActivity(intentLeg); } } catch(AndroidRuntimeException e) { e.printStackTrace(); } } } --------------------------------------------------------------------------------------------------------------- package com.vigyaapan.Exercise; import android.app.ListActivity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.ListView; public class TricepsViewController extends ListActivity { DBExercise dbExercise = new DBExercise(this); protected ListView lv; String[] aryTricepsList; public void onCreate(Bundle savedInstanceState) { try { super.onCreate(savedInstanceState); System.out.println("Inside Triceps class"); dbExercise.openDataBase(); aryTricepsList = dbExercise.getTriceps(); if(dbExercise != null) dbExercise.close(); setContentView(R.layout.triceps); lv = (ListView)this.findViewById(android.R.id.list); setTricepsList(); } catch(RuntimeException e) { e.printStackTrace(); } } /* * This method will get the populated values from database an load into list view of triceps list */ public void setTricepsList() { try { ArrayAdapter listItemAdapter = new ArrayAdapter (this,android.R.layout.simple_list_item_1,aryTricepsList); System.out.println("Array count===>"+listItemAdapter.getCount()); lv.setAdapter(listItemAdapter); } catch(RuntimeException e) { e.printStackTrace(); } } } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---