我的代码中遇到SuperNotCalledException
问题
我的活动包含NavigationDrawerFragment
,此Exception
只出现在" MOTOROLA"设备。你可以看到raw(Log)
here。
所以请帮助我过来。
这是我的代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
try {
super.onCreate(savedInstanceState);
} catch (Exception e) {
e.printStackTrace();
}
Crashlytics.start(this);
setContentView(R.layout.activity_landing);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
DrawerLayout drawer = (DrawerLayout) inflater.inflate(R.layout.decor, null); // "null" is important.
ViewGroup decor = (ViewGroup) getWindow().getDecorView();
View child = decor.getChildAt(0);
decor.removeView(child);
sharedHelper = new SharedHelper(LandingActivity.this);
FrameLayout container = (FrameLayout) drawer.findViewById(R.id.container); // This is the container we defined just now.
FrameLayout containerChild = (FrameLayout) drawer.findViewById(R.id.containerChild); // This is the container we defined just now.
container.removeView(containerChild);
container.addView(child);
container.addView(containerChild);
child.setClickable(true);
decor.addView(drawer);
actionBarHeight = getResources().getDimensionPixelSize(R.dimen.abc_action_bar_default_height_material);
mNavigationDrawerFragment = (NavigationDrawerFragment)
getFragmentManager().findFragmentById(R.id.navigation_drawer);
mTitle = getTitle();
mNavigationDrawerFragment.setUp(
R.id.navigation_drawer,
(DrawerLayout) findViewById(R.id.drawer_layout));
child.setClickable(true);
child.setFocusable(true);
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.containerChild, new RecentChatFragment())
.commit();
}
答案 0 :(得分:0)
你必须调用super.onCreate()作为第一条指令。