У меня есть диалоговое окно с предупреждением, в котором есть группа радиостанций из 5 кнопок. Когда нажимается OK, приложение отключается, выбрал ли я переключатель или нет. Идет разные методы для Radiogroup, но все не удается. Если кто-то может мне помочь, я буду благодарен.RadioGroup Inside Dialog Alert Сбой приложения Когда .позитивный
PS. У меня есть случай переключения, который вызывает эту активность диалогового окна Alert. colorpickdialog();
Это мой оповещения Dialog XML:
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/radiosizeg"
android:layout_below="@+id/bgadddialogsize"
android:layoutDirection="rtl"
android:gravity="start"
android:layout_gravity="start"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">
<RadioButton
android:text="@string/sizesmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/sizesmall"/>
<RadioButton
android:text="@string/sizemed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/sizemed" />
<RadioButton
android:text="@string/sizelar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/sizelar" />
<RadioButton
android:text="@string/sizefill"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/sizefill" />
<RadioButton
android:text="@string/sizecustom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/sizecustom" />
</RadioGroup>
и это мой MainActivity.class:
public void colorpickdialog() {
// get prompts.xml view
final RadioGroup radiosizeg = (RadioGroup) findViewById(R.id.radiosizeg);
LayoutInflater layoutInflater2 = LayoutInflater.from(MainActivity.this);
View promptView2 = layoutInflater2.inflate(R.layout.colorpickdialog, null);
AlertDialog.Builder alertDialogBuilder2 = new AlertDialog.Builder(MainActivity.this);
alertDialogBuilder2.setView(promptView2);
// setup a dialog window
alertDialogBuilder2.setCancelable(false)
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
radiosizeg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
int id = radiosizeg.getCheckedRadioButtonId();
switch (id) {
case R.id.sizesmall:
Toast.makeText(getApplicationContext(),"A", Toast.LENGTH_SHORT).show();
break;
case R.id.sizemed:
Toast.makeText(getApplicationContext(),"B", Toast.LENGTH_SHORT).show();
break;
case R.id.sizelar:
Toast.makeText(getApplicationContext(),"C", Toast.LENGTH_SHORT).show();
break;
case R.id.sizefill:
Toast.makeText(getApplicationContext(),"D", Toast.LENGTH_SHORT).show();
break;
case R.id.sizecustom:
Toast.makeText(getApplicationContext(),"E", Toast.LENGTH_SHORT).show();
break;
default:
onCheckedChanged(radioGroup, i);
break;
}
}
});
}
})
.setNegativeButton(getString(R.string.cancel),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
StackTrace ошибка
10-27 20:56:53.753 4312-4327/? E/ReportTools: This is not beta user build
10-27 20:56:53.959 4312-7462/? E/HsmCoreServiceImpl: onTransact in code is: 102
10-27 20:56:54.025 13521-13539/? E/HwLauncher: SettingsEx , no such field.
10-27 20:56:54.088 8152-8242/? E/PackageLogInfoManager: checkPackageLogState, cr: [email protected], packageNames: null
Сообщите логин –
Это не журнал ошибок. Обратите внимание, что нет '? E/'. У вас есть только информационные и предупреждающие сообщения. –
Эти журналы относятся ко всему приложению. отфильтровать журналы и отправить их снова. Если вы используете студию Android. вы можете увидеть опцию фильтра на правой стороне монитора Android – Shuddh