RadioButton插入函数式
请问怎么在RadioButton弄一条函数式进去,当按下这个键时,得数是根据这条函数式得出来的
请问怎么在RadioButton弄一条函数式进去,当按下这个键时,得数是根据这条函数式得出来的
 
                            2017-10-20
RadioButton是单选按钮,多个RadioButton放在一个RadioGroup控件中,也就是说每次只能有1个RadioButton被选中。
  //设置who_group的监听器,其实是一句代码,其参数是一个带有重构函数的对象
       who_group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {            
           public void onCheckedChanged(RadioGroup group, int checkedId) {                // TODO Auto-generated method stub
               if(checkedId == china.getId()){
                   Toast.makeText(MainActivity.this,"中国", Toast.LENGTH_SHORT).show();
               }                else if(checkedId == america.getId()){
                   Toast.makeText(MainActivity.this, "美国", Toast.LENGTH_SHORT).show();
               }                else if(checkedId == others.getId()){
                   Toast.makeText(MainActivity.this, "其它国家", Toast.LENGTH_SHORT).show();
               }
           }
       });      
举报