android: textView can't setText time from TimePicker -


I have a button and textView when I clicked the button, the time picker will appear. But, when I set one hour and minute and it is shown in the TextView, then unfortunately

closes my code:

  protected dialogue OnCreateDialog (int id) {switch (id) {case: TIME_DIALOG_ID: new time picture dialog is back (this, time picture listener, hour, minute, true); } Return tap; } Private TimePickerDialog.OnTimeSetListener timePickerListener = to see new TimePickerDialog.OnTimeSetListener () {public void onTimeSet (timepicker, integer selectedHour, integer selectedMinute) {h = selectedHour; Minute = selectedMinute; // Here is the error ================= What's wrong? TvDisplayTime.setText (new stringbilder). Append (pad (hour)) append (":"). Append (pad (min))); }}; // =============================== Private static string pad (int c) {if (c> = 10 ) Return String.valueOf (c); And return "0" + String.valueOf (c); }}  

Why do I try to set Hours and Minutes from TimePicker and always show error in TextView ??

Please help ...

login:

07-27 18: 14: 24.661: E / Spanblstringbilder (7324): SPAN_EXCLUSIVE_EXCLUSIVE Spain Can not have zero length 07-27 18: 14: 24.661: E / Spanelstringbuilder (7324): SPAN_EXCLUSIVE_EXCLUSIVE span can not have a zero length 07-27 18: 14: 30.901: D / Androidertime (7324): VM 07-27 18: 14: 30.901: W / Dalvikvm (7324): thread = 1: the thread is left with no exception exception (group = 0x42034438) 07-27 18: 14: 30.911: e / Android Rentaim (7324): fatal exception : Main 07-27 18: 14: 30.9 11: E / Android time (7324): java.lang.NullPointerException 07-27 18: 14: 30.911: E / AndroidRuntime (7324): 07. com.example.b_timepicker.MainActivity $ 1.onTimeSet (MainActivity.java:98) 07 -27 18: 14: 30.911: E / AndroidRuntime (7324): Android. App Time picture radiology Tree Notifetime Set (Time PictureDialog. JavaWife 01) 07-27 18: 14: 30.911: E / Androindertime (7324): On Android App Time PictureDialogog.OnClick (Time PictureDioog.Java -165) 07-27 18: 14: 30.911: E / Android Random ($ 7324): $ button on the com.android.internal.app.AlertControllerHandlerHandLames (Alert Controller .Java 167) 07- 27 18: 14: 30.911: e / AndroidRuntime (7324): 14: 30.911: e / AndroidRuntime (7324): android.os.Handler.dispatchMessage (Handler.java:99) on Android 07-27 18. O Looper Loop (Looper.java:137) 07-27 18: 14: 30.911: E / Android Random (7324): Android. App Aktivtitredkmain (Gtividhitreradkjawa 49, 49) 07-27 18:14: 30.911: E / AndroidRuntime (7324): java.lang.reflect.Method.invokeNative (Native Method) 18 07-27: 14: 30.911 e / AndroidRuntime (7324): on java.lang.reflect.Method.invoke (Method.java:511) 07-27 18: 14: 30.911: e / AndroidRuntime (7324): com on 07-27 18:14. Android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:1038): 30.911: E / AndroidRuntime (7324): com.android.internal.os.ZygoteInit.main (ZygoteInit.java:805) 07-27 18: 14: 30.911: E / AndroidRuntime (7324): On Dalvik.system.NativeStart.main (Basic Method)

Just make sure you have your tvDisplayTime TextView correctly The while, when you setText () call is not empty. Also make sure that tvDisplayTime is defined on the correct layout.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -