What I want to say
This evening I still write blog in the library, in fact, I am not excited at the moment, because tomorrow is the final of the football match, I as the main player pressure is very strong, because of the other side is very powerful, but then what. So-what ... I'm not going to stop blogging.
Numberpicker Introduction
Numberpicker This control allows you to swipe to select a value.
Set by three methods:
1.setMinValue ()
2.setMaxVlaue ()
3.setValue ()
code example
<?xml version= "1.0" encoding= "Utf-8"?><Tablelayout xmlns:android="Http://schemas.android.com/apk/res/android" Xmlns:tools="Http://schemas.android.com/tools" Android:layout_width="Match_parent" Android:layout_height="Match_parent" Android:paddingleft="@dimen/activity_horizontal_margin" Android:paddingright="@dimen/activity_horizontal_margin" Android:paddingtop="@dimen/activity_vertical_margin" Android:paddingbottom="@dimen/activity_vertical_margin" Tools:context=". Mainactivity " android:orientation="Vertical"> <TableRowandroid:layout_width="Fill_parent"android:layout_height= "Wrap_content"> <TextViewandroid:layout_width="120DP"android:layout_height= "Wrap_content" Android:text="Choose low Price"/> <numberpickerandroid:id= "@+id/np1"android:layout_width="Match_ Parent "android:layout_height=" 80DP "android:focusable=" true " Android:focusableintouchmode="true" /> </TableRow> <TableRowandroid:layout_width="Fill_parent"android:layout_height= "Wrap_content"> <TextViewandroid:layout_width= "120dp"android:layout_height=" Wrap_content "android:text=" Select low price "/> <numberpickerandroid:id= "@+id/np2"android:layout_width="Match_ Parent "android:layout_height=" 80DP "android:focusable=" true " Android:focusableintouchmode="true"/> </TableRow></tablelayout>
Package Peng. Liu. Test;Import Android. App. Activity;Import Android. Graphics. Color;Import Android. Graphics. drawable. Drawable;Import Android. OS. Bundle;Import Android. View. Gravity;Import Android. View. Layoutinflater;Import Android. View. View;Import Android. View. ViewGroup;Import Android. Widgets. Adapterview;Import Android. Widgets. Baseadapter;Import Android. Widgets. Button;Import Android. Widgets. CalendarView;Import Android. Widgets. DatePicker;Import Android. Widgets. EditText;Import Android. Widgets. Framelayout;Import Android. Widgets. GridView;Import Android. Widgets. Imageswitcher;Import Android. Widgets. ImageView;Import Android. Widgets. LinearLayout;Import Android. Widgets. Numberpicker;Import Android. Widgets. Simpleadapter;Import Android. Widgets. Textswitcher;Import Android. Widgets. TextView;Import Android. Widgets. Timepicker;Import Android. Widgets. Toast;Import Android. Widgets. Viewflipper;Import Android. Widgets. Viewswitcher;Import Java. Util. ArrayList;Import Java. Util. Calendar;Import Java. Util. HashMap;Import Java. Util. List;Import Java. Util. Map;public class Mainactivity extends Activity {private Numberpicker NP1,NP2;private int minValue = -;private int maxValue = the;@Override protected void OnCreate (Bundle savedinstancestate) {Super. OnCreate(savedinstancestate);Setcontentview (R. Layout. Activity_main);NP1 = (numberpicker) Findviewbyid (R. ID. NP1);NP2 = (numberpicker) Findviewbyid (R. ID. NP2);Np1. Setminvalue(Ten);Np1. Setmaxvalue( -);Np1. SetValue(MinValue);Np2. Setminvalue( -);Np2. Setmaxvalue( -);Np2. SetValue(MaxValue);Np1. Setonvaluechangedlistener(New Numberpicker. Onvaluechangelistener() {@Override public void Onvaluechange (numberpicker numberpicker, int i, int i2) { MinValue = I2;Shownumber ();} });Np2. Setonvaluechangedlistener(New Numberpicker. Onvaluechangelistener() {@Override public void Onvaluechange (numberpicker numberpicker, int i, int i2) { MaxValue = I2;Shownumber ();} });} public void Shownumber () {Toast. Maketext(this,minvalue+maxvalue+"", Toast. LENGTH_long). Show();}}
Android Digital Selector Numberpicker-android learning Journey (37)