开发者

activitygroup and currentactivity

I am having trouble with menus and activitygroups. I read this question and the issue I'm still having is that when I press back the currentactivity still seems to be the activity i just came back from, so the activitygroup is returning false for the menu when I press menu for the 1st activity, so its menu is no longer created. this is my group's back method:

   @Override
    public void onBackPressed() {
         if (this.getCurrentActivity() instanceof mpVoucherDetailsPage  || 
                 this.getCurrentActivity() instanceof MyVoucherDetailsPage){
            MapVouchers.theMap.enableLocationOverlay();
         }
         MapGroup.group.back();
   }

This is my group's menu methods:

   @Override
   public boolean onPrepareOptionsMenu(Menu menu) {
       System.out.println("onprepareoptionsmenu group called.");
       System.out.println( getLocalActivityManager().getCurrentActivity().onPrepareOptionsMenu(menu) );
       System.out.println(getLocalActivityManager().getCurrentActivity().getClass());
       return getLocalActivityManager().getCurrentActivity().onPrepareOptionsMenu(menu);
   }

   @Override
   public boolean onCreateOptionsMenu(Menu menu) {
       return getLocalActivityManager().getCurrentActivity().onCreateOptionsMenu(menu);
   }

   @Override
   public boolean onOptionsItemSelected(MenuItem item) {
       return getLocalActivityManager().getCurrentActivity().onOptionsItemSelected开发者_JAVA技巧(item);
   }

Is there any way to make it return the current view's menu instead of the currentactivity's(which the user no longer sees)?


I fixed this by using the activity group described on this page:

http://ericharlow.blogspot.com/2010/09/experience-multiple-android-activities.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜