startActivity之后界面一片空白(或显示:未找到匹配的活动)
程序员文章站
2022-06-04 14:51:30
...
使用ListActivity和LauncherActivity, startActivity之后界面一片空白(或显示:未找到匹配的活动)
控制台未保存,但提示:handleWindowVisibility: no activity for token
原因是 onCreate 方法有多个重载,我重载的那个onCreate 方法没有被调用
// 不会被调用的 onCreate 方法
@Override
public void onCreate( Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
String[] menus = new String[]{"程序设置","查看其它"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_multiple_choice,menus);
setListAdapter( adapter );
}
将上面方法改为:
@Override
public void onCreate( Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] menus = new String[]{"程序设置","查看其它"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_multiple_choice,menus);
setListAdapter( adapter );
}
转载于:https://www.jianshu.com/p/4f47e4f0f794