2017-05-09 36 views
0

を提供する必要があり、私はsignatured APKを生成しようとしましたが、その後、このエラーが表示されます:エラー:このクラスは、デフォルトコンストラクタに

Error:Error: This class should provide a default constructor (a public constructor with no arguments) (com.penta.games.mrpolitik.SpendenDialog) [Instantiatable]

これはどのように私はこのエラーを解決することができ、私のダイアログのファイル

package com.penta.games.mrpolitik; 

import android.app.Activity; 
import android.app.Dialog; 
import android.content.Intent; 
import android.net.Uri; 
import android.os.Bundle; 
import android.view.View; 
import android.view.Window; 
import android.widget.Button; 

public class SpendenDialog extends Dialog implements 
     android.view.View.OnClickListener { 

    private Activity c; 
    private Button yes, no; 

    public SpendenDialog(Activity a) { 
     super(a); 
     this.c = a; 
    } 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     requestWindowFeature(Window.FEATURE_NO_TITLE); 
     setContentView(R.layout.spenden_dialog); 
     yes = (Button) findViewById(R.id.btn_yes); 
     no = (Button) findViewById(R.id.btn_no); 
     yes.setOnClickListener(this); 
     no.setOnClickListener(this); 
    } 



    @Override 
    public void onClick(View v) { 
     switch (v.getId()) { 
      case R.id.btn_yes: 
       Uri uri = Uri.parse("https://patreon.com/user?u=5716519&utm_medium=social&utm_source=twitter&utm_campaign=creatorshare2"); 
       Intent intent = new Intent(Intent.ACTION_VIEW, uri); 
       c.startActivity(intent); 
       break; 
     } 
     switch (v.getId()) { 
      case R.id.btn_no: 
       break; 
     } 
     dismiss(); 
    } 



} 

です?

+0

cへのすべての元の参照を交換してお持ちください 'SpendenDialog 'マニフェストのどこかに記載されていますか? –

+0

エラーメッセージは誤解を招く、btwです。デフォルトのコンストラクタは、引数を持たない古い "パブリックコンストラクタ"だけではなく、クラスにコンストラクタが定義されていない場合はコンストラクタ_によって提供されます。 –

答えて

1

How can I solve this error?

ステップ#1:削除し、あなたのコンストラクタ

ステップ#2:あなたのcフィールド削除

ステップ#3:getContext()

関連する問題