My XML is trying to open a new activity button, looks like this:
& lt; Button Android: Eddie = "@ + id / button style" Android: Layout_width = "Fill_parent" Android: layout_height = "wrap_content" android: padding = "5 DP" android: text = "" android: onClick = "viewStyle" / & Gt; My button function looks like this:
Public Zero Scene Style (see View) {// Launch New Brew Page Category I = New Intent (this, breweriepage.class); I.putext ("myBeerObject", e); I.setClass (this, StylePage.class); StartActivity (i); } My Style Page. Java looks like this:
expansion of public class style page activity (get beer details from zero-protected by beeradata e. // bundle (bundle saved instenstate) {super.onCreate (SavedInstanceState) ; get data from setContentView (R.layout.brewery_page); // listview Intent intent = GetIntent (); Bundle B = Asykgetekstras (); e = Bikgetprselbl ( "myBeerObject"); // show title TextView Tvl = (TextView) findViewById (R.id.styleTitle); TextView tv2 = (TextView) findViewById (R.id.styleDescription); // show details tv1.setText (e.beerStyle); tv2.setText (e.beerStyleD Escription);}} My error is a null pointer exception:
06-20 22: 33: 48.210: E / Android time (29 9 4) ): fatal exception: main 06-20 22: 33: 48.210: e / AndroidRuntime (29,904): java.lang.RuntimeException: activity unable to start ComponentInfo {com.example.beerportfoliopro / com.example.beerportfoliopro.StylePage}: java.lang.NullPointerException 06 -20 22: 33: 48.210: e / AndroidRuntime (29,904): 33 :: 48.210: e / AndroidRuntime (29,904): android.app.ActivityThread.performLaunchActivity on android.app (ActivityThread.java:2307 ) 06-20 22 .ActivityThread.handleLaunchActivity (ActivityThread.javacember357) 06-20 22:33 33. 48.210: E / AndroidRuntime (29,904): android.app.ActivityThread.access $ 600 (ActivityThread.java:153) 06 -20 at 22:33 at: 48.210: E / AndroidRuntime (29,904): android.app.ActivityThread $ H.handleMessage (ActivityThread.java:1247) at 06-20 22:33 33. 48.210: E / AndroidRuntime (29,904): android.os.Handler.dispatchMessage (handler. Java: 99) 06-20 22: 33: 48.210: E / Android Randomime (2994): Android.OS. Looper Elope (Lo Oper.java:137) 06-20 22: 33: 48.210: E / Android Random (2994): Android. App ActivateTrade.Mine (ActivityTrade.Java 22222) 06-20 22: 33: 48.210: E / Android Retainman (29904): at java.lang.reflect.Method.invokeNative (Native Methods) 06-20 22:33 33: 48.210: E / Androordantum (2994): at java.lang.reflect.Method.invoke (Method.Pass 11) 06-20 22: 33: 48.210: E / AndroidRuntime (29,904): 33 :: 48.210: com.android.internal .os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:795) 06-20 e / AndroidRuntime (29904) in 22: com.android.internal.os.ZygoteInit.main (ZygoteInit.javaety62) 06-20 22: 33: 48.210: E / Android Time (2994): On Dalvik.system.NativeStart.main (Basic Method) 06-20 22: 33: 48.210: E / AndroidRuntime (29,904): java.lang.NullPointerException 06-20 22 :: 33: 48.210: Because of E / AndroidRuntime ( 29,904): com.example.beerportfoliopro.StylePage.onCreate at (StylePage.java:28) 06-20 22: 33: 48.210: E / Android Randomime (2994): Android. On the App Activity.Perform Create (Activity.JavaTT 104) 06-20 22: 33: 48.210: E / Android Time (29,904): Android. App Instrumentation.ActivityOncurt (instrumentation.java 1080) 06-20 22: 33: 48.210: E / ANDROIDERTUM (2994): Android. App ActivateTrade.Perform Lock Activity (ActivityTrad.Java 26261)
Logcat from you
Reason: java.lang.NullPointerException at Com.example.beerportfoliopro.StylePage.onCreate (StylePage.java:28) It clearly states that You have line 28 at nullpointerexception in the package stylepace class in the oncreate method in com.example.beerportfoliopro package And as you said that the line is 28
tv1.setText (e.beerStyle); So it seems that TV1 is zero. Or e-tap
TV1 can only be zero after this line
TextView tv1 = (TextView) findViewById (R.id.styleTitle); It is possible that you are pushing textView with the wrong ID. Check your layout XML and see if you are raising the correct ID.
and E may be blank in this line
e = b.getParcelable ("myBeerObject"); Then your recipient is returning empty ..
So the problem is either in two cases above. Check them both.
(This is just an estimate)
No comments:
Post a Comment