原因接收和QUOT; RadioGroup中是不适用的论点" [英] Reasons for receiving "RadioGroup is not applicable for the arguments"

查看:94
本文介绍了原因接收和QUOT; RadioGroup中是不适用的论点"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在执行 RadioGroup中在我的应用即可。对于我已导入进口android.widget.RadioGroup 实施OnCheckedChangeListener 。不过还是我得到这个错误:


  

该方法
  setOnCheckedChangeListener(RadioGroup.OnCheckedChangeListener)在
  类型RadioGroup中是不适用的参数(OpenedClass)


Java的:


  

OpenedClass.java


 公共类OpenedClass扩展活动实现OnClickListener,OnCheckedChangeListener {    TextView的TV1,TV2;
    RadioGroup中selectionList;
    按钮RTN;
    串gotBread;
    @覆盖
    保护无效的onCreate(捆绑savedInstanceState){
        // TODO自动生成方法存根
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.send);
        initlize();
        捆绑gotBusket = getIntent()getExtras()。
        gotBread = gotBusket.getString(KEY);
        tv1.setText(gotBread);    }
    私人无效initlize(){
        // TODO自动生成方法存根        TV1 =(的TextView)findViewById(R.id.tvQuestion);
        TV2 =(的TextView)findViewById(R.id.textView2);
        RTN =(按钮)findViewById(R.id.bReturn);
        rtn.setOnClickListener(本);
        selectionList =(RadioGroup中)findViewById(R.id.rgAnswers);
        selectionList.setOnCheckedChangeListener(本);
    }
    @覆盖
    公共无效的onClick(查看为arg0){
        // TODO自动生成方法存根    }
    @覆盖
    公共无效onCheckedChanged(CompoundButton为arg0,ARG1布尔){
        // TODO自动生成方法存根        开关(arg0.getId())
        {
        案例R.id.rCrazy:
            打破;
        案例R.id.rSuper:
            打破;
        案例R.id.rBoth:
            打破;
        }    }}


解决方案

您导入了不正确的类 OnCheckedChangeListener RadioGroup中

替换为:

 进口android.widget.CompoundButton.OnCheckedChangeListener;

这一个:

 进口android.widget.RadioGroup.OnCheckedChangeListener;

和解决如下的接口实现:

  @覆盖
公共无效onCheckedChanged(RadioGroup中组,诠释checkedId){
   开关(checkedId)
   {
      //你的情况下,
   }
}

I am implementing RadioGroup in my application. For that I have imported import android.widget.RadioGroup and implemented OnCheckedChangeListener. But still I am getting this error:

The method setOnCheckedChangeListener(RadioGroup.OnCheckedChangeListener) in the type RadioGroup is not applicable for the arguments (OpenedClass)

Java:

OpenedClass.java

public class OpenedClass extends Activity implements OnClickListener,OnCheckedChangeListener{

    TextView tv1,tv2;
    RadioGroup selectionList;
    Button rtn;
    String gotBread;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.send);
        initlize();
        Bundle gotBusket = getIntent().getExtras();
        gotBread = gotBusket.getString("KEY");
        tv1.setText(gotBread);

    }
    private void initlize() {
        // TODO Auto-generated method stub

        tv1 = (TextView)findViewById(R.id.tvQuestion);
        tv2 = (TextView)findViewById(R.id.textView2);
        rtn = (Button)findViewById(R.id.bReturn);
        rtn.setOnClickListener(this);
        selectionList = (RadioGroup)findViewById(R.id.rgAnswers);
        selectionList.setOnCheckedChangeListener(this);
    }
    @Override
    public void onClick(View arg0) {
        // TODO Auto-generated method stub

    }
    @Override
    public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
        // TODO Auto-generated method stub

        switch(arg0.getId())
        {
        case R.id.rCrazy:
            break;
        case R.id.rSuper:
            break;
        case R.id.rBoth:
            break;
        }

    }



}

解决方案

You are importing an incorrect class of OnCheckedChangeListener for RadioGroup.

Replace:

import android.widget.CompoundButton.OnCheckedChangeListener;

with this one:

import android.widget.RadioGroup.OnCheckedChangeListener;

and fix your interface implementation as below:

@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
   switch(checkedId)
   {
      //your cases
   }
}

这篇关于原因接收和QUOT; RadioGroup中是不适用的论点"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆