0
我有一个警报对话框,有一个5个按钮的Radiogroup。当按下OK时,应用程序会崩溃,无论我是否选择单选按钮。为Radiogroup尝试了不同的方法,但都失败了。如果有人能帮助我,我会很感激。RadioGroup Inside对话框警报崩溃应用程序时。崩溃
PS。我有一个正在调用此警报对话活动的开关盒。 colorpickdialog();
这是我的警告对话框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();
}
});
错误堆栈跟踪
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 studio。你可以看到Android监视器右侧的过滤器选项 – Shuddh