Android中的NumberPicker是垂直顯示的,上面有增加和減少的按鈕,下面顯示數字。是否有辦法讓NumberPicker水平顯示嗎?讓按鈕在左邊顯示,右邊顯示數字。
valueText.addTextChangedListener(new TextWatcher() {
private int backupValue;
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
backupValue = value;
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) { }
@Override
public void afterTextChanged(Editable s) {
String string = s.toString().trim();
if(string.equals("")) {
setValue(1);
return;
}
try {
value = Integer.parseInt(s.toString());
if(value > MAXIMUM) {
setValue(MAXIMUM);
}
} catch( NumberFormatException nfe ){
setValue(backupValue);
}
}
});