开发者

Problem in displaying in Edit text values corresponding to spinner value

开发者 https://www.devze.com 2023-03-05 09:41 出处:网络
I have a spinner in my layout and according to the values of a spinner i want to change the values of edit text. in the same layout.

I have a spinner in my layout and according to the values of a spinner i want to change the values of edit text. in the same layout.

For example :- i have 2 Edit Text Boxes and 1 spinner开发者_StackOverflow社区 in the layout and in spinner i have 2 values (Fahrenheit and Celsius) and the edit text should display the temperature selected through spinner immediately.

Like i have values 50 and 20 in edit boxes and Celsius in spinner..If i select Fahrenheit then values in edit boxes change to 122 and 68 immediately on the same layout.

can any tell me how can i implement this ?


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

        }
    });
0

精彩评论

暂无评论...
验证码 换一张
取 消