我的程序是工作。嗯...我尝试在消息 AlertDialog 中显示结果,它不起作用。可以工作吗?
package diahp.d;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
public class example extends Activity implements OnClickListener {
CheckBox jimmy,diana,dina,jack;
RadioButton yes,no;
RadioGroup radioGroup;
TextView status;
StringBuilder showing;
Button show;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.example);
jimmy = (CheckBox) findViewById(R.id.jimmy);
diana = (CheckBox) findViewById(R.id.diana);
dina = (CheckBox) findViewById(R.id.dina);
jack = (CheckBox) findViewById(R.id.jack);
jimmy.setOnClickListener(this);
diana.setOnClickListener(this);
dina.setOnClickListener(this);
jack.setOnClickListener(this);
yes = (RadioButton) findViewById(R.id.yes);
no = (RadioButton) findViewById(R.id.no);
yes.setOnClickListener(this);
no.setOnClickListener(this);
status = (TextView) findViewById(R.id.status);
radioGroup = (RadioGroup) findViewById(R.id.radioGroup);
show = (Button) findViewById(R.id.show);
show.setOnClickListener(this);
}
public void onClick(View v) {
showing = new StringBuilder();
if (yes.isChecked()) {
diana.setEnabled(true);
jimmy.setEnabled(true);
dina.setEnabled(true);
jack.setEnabled(true); }
if(no.isChecked()) {
diana.setChecked(false);
jimmy.setChecked(false);
dina.setChecked(false);
jack.setChecked(false);
}
if(diana.isChecked())
{showing.append("Diana");}
if(jimmy.isChecked())
{showing.append("Jimmy");}
if(dina.isChecked())
{showing.append("Dina");}
if(jack.isChecked())
{showing.append("Jack");}
switch (v.getId()) {
case R.id.show:
AlertDialog.Builder about = new AlertDialog.Builder(this);
//*******I want this result in pop up alert, could it be?*******************
status.setText(showing);
//****************************************************
about.setMessage(" ").setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog title = about.create();
title.setTitle("RESULT");
title.setIcon(R.drawable.acon);
title.show();
}}}
我的程序是工作。我检查了复选框,结果是名称杰克等。嗯...当我单击按钮时,我尝试在消息 AlertDialog 中显示结果,但它不起作用。alertdialog 出现了,但结果什么也没有。可以工作吗?