*But what could I do so that the Flipper displays the ListView correctly when the button is pressed because I am not even sure if my attempt was going into the right direction as I didn't know how to include the childView while setting up the listView at the same time. * * * *I also tried around a little to find out why lv is null, from what I have tried it seems that the String [] array is null. I followed this example to set up and call the array in XML: http://developer.android.com/resources/tutorials/views/hello-listview.html * On Mon, Aug 2, 2010 at 9:52 PM, Mark Murphy <mmur...@commonsware.com> wrote:
> No, it means your variable lv is null. > > On Mon, Aug 2, 2010 at 4:43 PM, Victoria Busse > <victoriasarabu...@gmail.com> wrote: > > The Logcat says that there is a 08-02 22:33:45.704: > > ERROR/AndroidRuntime(6918): java.lang.NullPointerException > > 08-02 22:33:45.704: > > ERROR/AndroidRuntime(6918): at > > com.mobilevideoeditor.moved.EditorView.onClick(EditorView.java:82), which > > is lv.setAdapter(new ArrayAdapter<String>(this, > > R.layout.specialeffectsview, specialEffects)); but this would mean that > > R.layout.specialeffectsview doesn't exist, or? And it definitely does > (below > > is the code I use for the specialeffectsview.xml) > > <?xml version="1.0" encoding="utf-8"?> > > <LinearLayout android:id="@+id/view_special_effects_list" > > android:layout_width="fill_parent" > > android:layout_height="fill_parent" > > xmlns:android="http://schemas.android.com/apk/res/android"> > > <ListView android:id="@+id/special_effects_list" > > android:layout_height="wrap_content" > > android:layout_width="fill_parent"></ListView> > > </LinearLayout> > > > > > > This is the entire logcat output: > > 08-02 22:33:45.694: ERROR/AndroidRuntime(6918): Uncaught handler: thread > > main exiting due to uncaught exception > > 08-02 22:33:45.704: ERROR/AndroidRuntime(6918): > > java.lang.NullPointerException > > 08-02 22:33:45.704: ERROR/AndroidRuntime(6918): at > > com.mobilevideoeditor.moved.EditorView.onClick(EditorView.java:82) > > 08-02 22:33:45.704: ERROR/AndroidRuntime(6918): at > > android.view.View.performClick(View.java:2364) > > 08-02 22:33:45.704: ERROR/AndroidRuntime(6918): at > > android.view.View.onTouchEvent(View.java:4179) > > 08-02 22:33:45.704: ERROR/AndroidRuntime(6918): at > > android.view.View.dispatchTouchEvent(View.java:3709) > > 08-02 22:33:45.704: ERROR/AndroidRuntime(6918): at > > android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:924) > > 08-02 22:33:45.704: ERROR/AndroidRuntime(6918): at > > android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:924) > > 08-02 22:33:45.704: ERROR/AndroidRuntime(6918): at > > android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:924) > > 08-02 22:33:45.704: ERROR/AndroidRuntime(6918): at > > android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:924) > > 08-02 22:33:45.704: ERROR/AndroidRuntime(6918): at > > android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:924) > > 08-02 22:33:45.704: ERROR/AndroidRuntime(6918): at > > > com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1695) > > 08-02 22:33:45.704: ERROR/AndroidRuntime(6918): at > > > com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1116) > > 08-02 22:33:45.704: ERROR/AndroidRuntime(6918): at > > android.app.Activity.dispatchTouchEvent(Activity.java:2068) > > 08-02 22:33:45.704: ERROR/AndroidRuntime(6918): at > > > com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1679) > > 08-02 22:33:45.704: ERROR/AndroidRuntime(6918): at > > android.view.ViewRoot.handleMessage(ViewRoot.java:1724) > > 08-02 22:33:45.704: ERROR/AndroidRuntime(6918): at > > android.os.Handler.dispatchMessage(Handler.java:99) > > 08-02 22:33:45.704: ERROR/AndroidRuntime(6918): at > > android.os.Looper.loop(Looper.java:123) > > 08-02 22:33:45.704: ERROR/AndroidRuntime(6918): at > > android.app.ActivityThread.main(ActivityThread.java:4603) > > 08-02 22:33:45.704: ERROR/AndroidRuntime(6918): at > > java.lang.reflect.Method.invokeNative(Native Method) > > 08-02 22:33:45.704: ERROR/AndroidRuntime(6918): at > > java.lang.reflect.Method.invoke(Method.java:521) > > 08-02 22:33:45.704: ERROR/AndroidRuntime(6918): at > > > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) > > 08-02 22:33:45.704: ERROR/AndroidRuntime(6918): at > > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) > > 08-02 22:33:45.704: ERROR/AndroidRuntime(6918): at > > dalvik.system.NativeStart.main(Native Method) > > > > On Mon, Aug 2, 2010 at 9:30 PM, Mark Murphy <mmur...@commonsware.com> > wrote: > >> > >> If your error report is accurate, you are not setting lv to a value, > >> and so it is null. > >> > >> On Mon, Aug 2, 2010 at 4:25 PM, kivy <victoriasarabu...@gmail.com> > wrote: > >> > Hi > >> > > >> > I am trying to populate a ViewFlipper with a ListView when a certain > >> > button is clicked...but I only get a NullPointerException for > >> > lv.setAdapter(new ArrayAdapter<String>(this, > >> > R.layout.specialeffectsview, specialEffects)); > >> > > >> > To be honest I don't really know how to do this, I just learned about > >> > the ViewFlipper today and I haven't fully understood how to use it > >> > yet. If anyone could help me find how what I have done wrong, that > >> > would be great. > >> > > >> > Thanks in advance. > >> > > >> > Here is the code I use: > >> > > >> > public void onClick(View v){ > >> > if (v == btnExposure){ > >> > > >> > mFlipper.setDisplayedChild(0); > >> > > >> > } > >> > else if (v == btnProperties){ > >> > mFlipper.setDisplayedChild(1); > >> > } > >> > > >> > else if (v == btnSpecialEffects){ > >> > mFlipper.setDisplayedChild(2); > >> > String[] specialEffects = > >> > getResources().getStringArray(R.array.special_effects_array); > >> > lv.setAdapter(new ArrayAdapter<String>(this, > >> > R.layout.specialeffectsview, specialEffects)); > >> > lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE); > >> > } > >> > > >> > } > >> > > >> > -- > >> > You received this message because you are subscribed to the Google > >> > Groups "Android Developers" group. > >> > To post to this group, send email to > android-developers@googlegroups.com > >> > To unsubscribe from this group, send email to > >> > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> > >> > For more options, visit this group at > >> > http://groups.google.com/group/android-developers?hl=en > >> > > >> > >> > >> > >> -- > >> Mark Murphy (a Commons Guy) > >> http://commonsware.com | http://github.com/commonsguy > >> http://commonsware.com/blog | http://twitter.com/commonsguy > >> > >> _Android Programming Tutorials_ Version 2.9 Available! > >> > >> -- > >> You received this message because you are subscribed to the Google > >> Groups "Android Developers" group. > >> To post to this group, send email to > android-developers@googlegroups.com > >> To unsubscribe from this group, send email to > >> android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> > >> For more options, visit this group at > >> http://groups.google.com/group/android-developers?hl=en > > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" group. > > To post to this group, send email to android-developers@googlegroups.com > > To unsubscribe from this group, send email to > > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> > > For more options, visit this group at > > http://groups.google.com/group/android-developers?hl=en > > > > -- > Mark Murphy (a Commons Guy) > http://commonsware.com | http://github.com/commonsguy > http://commonsware.com/blog | http://twitter.com/commonsguy > > _Android Programming Tutorials_ Version 2.9 Available! > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en