[英]Auto open drawable after start app android
I want Auto open drawable after start app android我想在启动应用程序 android 后自动打开可绘制对象
used library https://github.com/mikepenz/MaterialDrawer使用库https://github.com/mikepenz/MaterialDrawer
this code from Main Activity If it possible if possible And the second question is, can I open the menu on all activities after the swipe to the right?此代码来自 Main Activity 如果可能的话第二个问题是,我可以在向右滑动后打开所有活动的菜单吗? Only the back button now works现在只有后退按钮有效
drawer = new DrawerBuilder()
.withActivity(this)
.withToolbar(mToolbar)
.withSelectedItem(1)
.withAccountHeader(headerResult)
.addDrawerItems(
new PrimaryDrawerItem().withIdentifier(1).withName(R.string.Home).withIcon(FontAwesome.Icon.faw_home),
new PrimaryDrawerItem().withIdentifier(2).withName(R.string.News).withIcon(FontAwesome.Icon.faw_newspaper),
new PrimaryDrawerItem().withIdentifier(3).withName("About").withIcon(FontAwesome.Icon.faw_question_circle),
new PrimaryDrawerItem().withIdentifier(4).withName("Open Source").withIcon(FontAwesome.Icon.faw_github_square),
new PrimaryDrawerItem().withIdentifier(5).withName("Rate on Google Play").withIcon(FontAwesome.Icon.faw_thumbs_up)
)
.withTranslucentStatusBar(false)
.build();
drawer.setOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
switch (position) {
case 1:
drawer.closeDrawer();
return true;
case 2:
drawer.closeDrawer();
drawer.setSelection(1);
startActivity(new Intent(context, NewsListActivity.class));
return true;
case 3:
drawer.closeDrawer();
drawer.setSelection(1);
startActivity(new Intent(context, AboutTheDevActivity.class));
return true;
case 4:
drawer.closeDrawer();
drawer.setSelection(1);
libsBuilder.start(context);
default:
return true;
}
}
});
I suggest to refactor your application to single activity structure.我建议将您的应用程序重构为单一活动结构。 This will help to solve both of your problems.这将有助于解决您的两个问题。
onCreate
method.您可以在活动onCreate
方法中打开抽屉。 It is called when activity created, with single activity - when app started.它在创建活动时调用,具有单个活动 - 当应用程序启动时。Single activity is the way google recommends to structure apps.单一活动是谷歌推荐的构建应用程序的方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.