2012-06-19 27 views
0

增加和減少的值......像日期選擇我想要像這樣在安卓UI在Android電子

value picker

這是日期選擇器的一部分,那麼,如何將其解壓到只使用價值選擇器。

如果不適用於此操作,請告訴我有關其他方法。

+0

嘗試修改此輪視圖http://code.google.com/p/and roid-wheel/downloads/detail?name = wheel-demo-2.1.zip&can = 2&q = –

+1

https://github.com/mrn/numberpicker – Th0rndike

+0

請不要複製iOS車輪。它是可怕的。 –

回答

1

標準android NumberPicker小部件看起來完全如此。不幸的是,它僅適用於Android 3.0及更高版本,因此如果您定位的是早期版本,則需要使用庫。

Android版本的文檔可以找到here

由於其他人已經指出你可能的圖書館,我不會在這裏重複。我將向您展示如何使用標準的NumberPicker for Android 3.0+。

在XML佈局(設置寬度爲100浸允許三位數,調整根據需要):

<NumberPicker 
    android:id="@+id/numberpicker" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:width="100dip" /> 

在您的代碼:

NumberPicker np = (NumberPicker) findViewById(R.id.numberpicker); // get the widget 
np.setMaxValue(10);             // set the max value 
np.setMinValue(0);             // set the min value 
np.setValue(5);             // set initail display value 
np.setWrapSelectorWheel(true);          // start over when reaching top or bottom 

和屏幕截圖的它:

enter image description here