【问题标题】:Error:(28) Error: This class should provide a default constructor (a public constructor with no arguments) (myclassname.HelpDialog) [Instantiatable]错误:(28)错误:此类应提供默认构造函数(没有参数的公共构造函数)(myclassname.HelpDialog)[Instantiatable]
【发布时间】:2015-01-23 13:25:39
【问题描述】:

在调试模式下编译时一切正常。但是在 Release 配置中编译时,出现以下错误:

错误:(28)错误:此类应提供默认构造函数(不带参数的公共构造函数)(myclassname.HelpDialog)[Instantiatable]

这是代码

public class HelpDialog extends Dialog {

    Activity mActivity;
    Button btn_go_back;   

    public HelpDialog(Activity mactivity) {
        super();
        this.mActivity = mactivity;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.dialog_help);   

        btn_go_back = (Button)findViewById(R.id.btn_help_go_back);

        btn_go_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }
}

【问题讨论】:

    标签: android class constructor android-studio


    【解决方案1】:

    添加这个兄弟:

    public HelpDialog( ){ 
      super(null);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-19
      相关资源
      最近更新 更多