我正在 x86_64 和 x86 模拟器中测试 Android 应用程序,在从显示列表的 AlertDialog 中选择一个项目后,它崩溃了(Android 模拟器意外关闭)。 AlertDialog 是从 AppCompatActivity 扩展的类中的 onOptionsItemSelected 重写方法调用的。
一些代码:
public class ListViewActivity extends AppCompatActivity {
private static final String TAG = "android-user-interface";
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Toast.makeText(this, "Item de menu seleccionado", Toast.LENGTH_SHORT).show();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("titulo")
.setItems(new String[]{"uno", "dos", "tres"}, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//fails before this
}
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
//return super.onOptionsItemSelected(item);
return true;
}
//...
}
在崩溃窗口中我得到了
Operating system: Windows NT
10.0.10586
CPU: amd64
family 6 model 60 stepping 3
8 CPUs
Crash reason: EXCEPTION_ACCESS_VIOLATION_READ
Crash address: 0x18
Assertion: Unknown assertion type 0x00000000
Process uptime: not available
... more info
关于这个问题的一些想法/信息?
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)