Saturday 15 August 2015

Android: NumberPicker does not behave properly -


There are two number picker in a layout to me and I'm using the layout for a AlertDialog box. However, there are no scrollers in the two number pickers, which are used to increase / decrease the price. Besides, I'm not also able to enable manual input values. Please help me find bugs.

Dialog.xml

  & Lt ;? Xml version = "1.0" encoding = "utf-8" & gt; & Lt; RelativeLayout xmlns: android = "http://schemas.android.com/apk/res/android" Android: layout_width = "match_parent" Android: layout_height = "match_parent" & gt; & Lt; LinearLayout android: id = "@ + id / llinner" android: orientation = "horizontal" android: Layout_width = "Wrap_content" Android: Layout_height = "Wrap_content" Android: layout_alignParentTop = "true" Android: layout_centerHorizontal = "true" & gt; & Lt; NumberPicker android: id = "@ + id / attnp1" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" / & gt; & Lt; LinearLayout android: id = "@ + id / llinnermost" android: orientation = "vertical" android: Layout_width = "Wrap_content" Android: Layout_height = "Wrap_content" Android: paddingTop = "50sp" & gt; & Lt; TextView android: id = "@ + id / innertv" Android: Layout_width = "Wrap_content" Android: Layout_height = "Wrap_content" android: text = "out of Android": TextSize = "20sp" Android: PaddingLeft = "L5sp" Android: PaddingRight = "15sp" /> & Lt; / LinearLayout & gt; & Lt; NumberPicker Android: id = "@ + id / attnp2" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" /> & Lt; / LinearLayout & gt; & Lt; / RelativeLayout & gt;   

snipper code activity that reaches this layout:

  LayoutInflater LF = LayoutInflater.from (List_of_Courses.this); Final View DialogView = lf.inflate (R.layout.dialog, null); Last Number Picture NP1 = (Number Picture) DialogView.findViewById (R.id.attnp1); Last Number Picture NP2 = (Number Picture) DialogView.findViewById (R.id.attnp2); Np1.setValue (prevatt); Np2.setValue (prevtot); Last AlertDialog Builder Alert = New AlertDialog. Builder (List_of_Courses.this); Alert .Cetital (CN + "- Presence"). SetView (DialogView) .setPositiveButton ("OK", New DialogInterface.OnClickListener () {@Override Public Zero (DialogInterface dialogue, Int jabuton) {if (np1.getValue () = = 0 || np2.getValue ( ) == 0) Return; Integer att = np1.getValue (); Integer value = np2.getValue (); if (att  

If you select minimum and Maximum values ​​for NumberPicker , increment / decreasing buttons will not appear.

You can use it and like it:

  np1.setMaxValue (max); Np1.setMinValue (minimum);    

No comments:

Post a Comment