我试图获取几个 numpickers 的值并将它们加在一起以显示在 TextView 上。我试图获取 textview 字符串并向我的号码选择器添加任何更改。正如
current_number_text= (TextView) findViewById(R.id.current_number);
NumberPicker np1 = (NumberPicker) findViewById(R.id.npId);
NumberPicker np2 = (NumberPicker) findViewById(R.id.npId2);
np1.setOnValueChangedListener(new OnValueChangeListener()
{
public void onValueChange(NumberPicker picker, int oldVal,
int newVal)
{
current_number_text.setText("" + (newVal * 10));
current_weight_view.setText("" + (newVal + np1.getValue() + np2.getValue()));
}
});
np2.setOnValueChangedListener(new OnValueChangeListener()
{
public void onValueChange(NumberPicker picker, int oldVal,
int newVal)
{
current_weight_view.setText("" + (newVal + np1.getValue() + np2.getValue()));
}
});
所以基本上我只想newVal
在每个数字选择中添加字符串,然后在 current_number_text TextView 中显示。