0
我有一個有4個單選按鈕的收音機組。而且我希望在檢查兩個特定單選按鈕中的任何一個時彈出對話框以彈出。我如何實現這一目標?我想要一個警告對話框來檢查單選按鈕
我有一個有4個單選按鈕的收音機組。而且我希望在檢查兩個特定單選按鈕中的任何一個時彈出對話框以彈出。我如何實現這一目標?我想要一個警告對話框來檢查單選按鈕
both = (RadioButton) findViewById(R.id.both);
RadioGroup radioGroup = (RadioGroup) findViewById(R.id.rgroup);
assert radioGroup != null;
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
{
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (veg.isChecked()) {
proof="veg";
//Toast.makeText(getApplicationContext(),proof,Toast.LENGTH_SHORT).show();
} else if(nonv.isChecked()) {
proof="non veg";
//Toast.makeText(getApplicationContext(),proof,Toast.LENGTH_SHORT).show();
}
else if (both.isChecked()){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("GPS is off"); // GPS not found
builder.setMessage("Turn on location services"); // Want to enable?
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int i) {
ConnectToWifi.this.startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
}
});
builder.setNegativeButton("No", null);
builder.create().show();
}
}
});