我的代码中遇到 SuperNotCalledException
问题。
我有一个包含 NavigationDrawerFragment
的 Activity,并且此 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();
}
最佳答案
您必须调用 super.onCreate() 作为第一条指令。
关于java - Android 中的 SuperNotCalledException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32268763/