How to manage multiples activities under a single tab of TabActivity

前端 未结 3 1728
礼貌的吻别
礼貌的吻别 2020-12-29 16:43

Here\'s the problem. In my app, I have 5 tabs which contains activities. In each of them, I have to show differents screens. For example, the main activity of a tab is a lis

相关标签:
3条回答
  • 2020-12-29 17:11

    I have still a problem with this code. I don't know how to handle the android back button. I have a graphical button to going back to the last activity with the method shown above, but if I try to add this behavior on the physical back button of the device, it doesn't work. I tried with onKeyPressent with the KEY_BACK event, but it never goes in this code section.

    Moreover, with this technique of subactivites, I don't have the sliding animation when I launch a new one. I try to add the animation manually, but I may not use the good technique, because it's laggy :

    public void replaceContentView(String id, Intent newIntent, int flag) {
        View view = mLocalActivityManager.startActivity(id, newIntent.addFlags(flag)).getDecorView();   
    
        Animation animation = AnimationUtils.loadAnimation(this, R.anim.slide_right);
        view.startAnimation(animation); 
        this.setContentView(view); 
    }
    

    Thanks

    0 讨论(0)
  • 2020-12-29 17:19

    I had this same question I believe I have a pretty good answer with some code examples on this blog article I just wrote. multiple-android-acitivities

    Let me know if it is helpful, or needs improvement.

    0 讨论(0)
  • 2020-12-29 17:21

    Ok, the solution (given on the site above), was this :

    this.m_backButton.setOnClickListener(new OnClickListener() { 
      @Override 
      public void onClick(View v) {
      Intent intent = new Intent(v.getContext(), Activity1.class);
      Activity1 parentActivity = (Activity1)getParent();  
      parentActivity.replaceContentView("activity1", intent, 
                     Intent.FLAG_ACTIVITY_REORDER_TO_FRONT ); 
      }
    });
    

    and take out my main activitity from ActivityGroup. You can see the answer here : http://gamma-point.com/content/android-how-have-multiple-activities-under-single-tab-tabactivity#comment-4

    0 讨论(0)
提交回复
热议问题