Android 反转滚动方向编号器
如何反转NumberPicker的滚动方向Android 反转滚动方向编号器,android,numberpicker,Android,Numberpicker,如何反转NumberPicker的滚动方向 我想让0上面的1成为一个简单的onCreate方法 @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.something); final TextView tv = (TextView) findViewById(R.id.tv);
我想让0上面的1成为一个简单的onCreate方法
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.something);
final TextView tv = (TextView) findViewById(R.id.tv);
NumberPicker np = (NumberPicker) findViewById(R.id.np);
final String[] values = {"1", "0"};
np.setMinValue(0);
np.setMaxValue(values.length - 1);
np.setDisplayedValues(values);
np.setWrapSelectorWheel(true);
np.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
String result = "Currently selected value:" + values[newVal];
tv.setText(result);
}
});
}
。。。还有一个简单的something.xml
:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<NumberPicker
android:id="@+id/np"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/np" />
</RelativeLayout>