在我的菜单我有一些项目。 Home是我想要成为我的应用程序的根的一个项目,每当用户点击它时,Android清除栈然后回到主屏幕。的Android,Intent.FLAG_ACTIVITY_CLEAR_TOP似乎不起作用?
这是我的代码:
menu.setOnItemClickedListener(new MenuClickedListener() {
public void eventOccured(int id) {
Intent intent = null;
switch(id) {
case 1: intent = new Intent(context, More.class); break;
case 2: intent = new Intent(context, FavoriteScreen.class); break;
case 3: intent = new Intent(context, VideoShowList.class); break;
case 4: intent = new Intent(context, ShoppingList.class); break;
case 5: intent = new Intent(context, MainScreen.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
break;
}
if(intent != null)
context.startActivity(intent);
}
});
菜单工作正常,但似乎标志并不因为从主屏幕上的工作,我去第二和第三屏幕,然后我点击菜单的首页项目回来到主屏幕。现在,当我点击后退按钮时,我转到第三屏幕,第二屏幕和主屏幕。
我设计了这个菜单,窗口小部件,以建立它一次,并重新使用我所有的屏幕。
任何建议,将不胜感激。谢谢。
我以为是一样的,原因'混乱的是,如果没有添加标志,那么我们使用addFlag()else setFlag()什么鱼! – 2012-08-14 05:19:42