我正在尝试在我的Android应用程序中创建一个新的Mari.java并在其上调用execute方法但它无效。我该如何解决?
Kelima.java
package com.example.dell.ayongaji;
import android.content.DialogInterface;
import android.content.Intent;
import android.media.ExifInterface;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
public class Kelima extends AppCompatActivity {
AlertDialog.Builder builder;
RadioGroup radiogroup;
//deklarasi var or obj
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.kelima);
getSupportActionBar().setTitle("OneDayOneHuruf");
//getSupportActionBar().setSubtitle("Belajar di okedroid.com");
//radiogroup inisialisasi
radiogroup = (RadioGroup) findViewById(R.id.radioGroup);
}
//Memilih RadioButton
public void onRadioButton(View view) {
Boolean checked = ((RadioButton) view).isChecked();
switch (view.getId()) {
case R.id.radioButton:
if (checked)
jawabanSalah();
break;
case R.id.radioButton2:
if (checked)
jawabanSalah();
break;
case R.id.radioButton3:
if (checked)
tampilDialog();
break;
case R.id.radioButton4:
if (checked)
jawabanSalah();
break;
}
}
//menampilkan dialog
public void tampilDialog() {
builder = new AlertDialog.Builder(this);
builder.setCancelable(false);
builder.setTitle("Selamat !!!");
builder.setMessage("Jawaban anda benar");
builder.setPositiveButton("OKE", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Intent ii = new Intent (Kelima.this, Mari.this);
startActivity(ii);
}
});
builder.setNegativeButton("ULANGI", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
radiogroup.clearCheck();
}
});
builder.create().show();
}
//menampilkan toast text jawaban salah
public void jawabanSalah(){
Toast.makeText(this, "Jawaban anda Salah", Toast.LENGTH_SHORT).show();
}
}
Mari.Java
package com.example.dell.ayongaji;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.content.Intent;
public class Mari extends AppCompatActivity {
TextView ff;
Button metu;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mari);
ff=(TextView)findViewById(R.id.ggg);
metu=(Button)findViewById(R.id.button) ;
getSupportActionBar().setTitle("OneDayOneHuruf");
metu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
AlertDialog.Builder alertexit = new AlertDialog.Builder(
Mari.this);
alertexit
.setMessage("Apakah Anda Akan Keluar Dari Aplikasi ini?")
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle("Keluar")
.setCancelable(false)
.setPositiveButton("ya",
new AlertDialog.OnClickListener() {
@Override
public void onClick(DialogInterface arg0,
int arg1) {
System.exit(0);
}
})
.setNegativeButton("tidak",
new AlertDialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
dialog.cancel();
}
});
AlertDialog a = alertexit.create();
a.show();
}
});
}
}