我的布局中有一个微调器,根据微调器的值,我想更改编辑文本的值。在相同的布局中。
例如: - 我在布局中有2个编辑文本框和1个微调器,在微调器中我有2个值(华氏温度和摄氏温度),编辑文本应该立即显示通过微调器选择的温度。
就像我在编辑框中有值50和20以及在微调器中有摄氏度。如果我选择华氏度,则编辑框中的值会立即在同一布局上更改为122和68.
可以告诉我如何实现这个?
答案 0 :(得分:0)
spinner.setOnItemSelectedListener(new OnItemSelectedListener(){
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int position, long arg3) {
// TODO Auto-generated method stub
if(position==0){
editText1.setText("50");
editText2.setText("20");
}else if (position==1){
editText1.setText("122");
editText2.setText("68");
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});