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();
}
}
});