如何管理TabActivity单选项卡下的倍数活动倍数、选项卡、TabActivity

2023-09-04 03:17:29 作者:最好听的长:最美的字是妳的名字

这里的问题。在我的应用程序,我有5个标签页,其中包含的活动。在他们每个人的,我必须展示型动物屏幕。例如,标签的主要活动是一个列表视图,当我点击它的项目之一,我想显示第二个屏幕,与其他的ListView,这将显示其他画面时,用户将选择项目等。

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 listview, and when I click on one of its item, I want to display a second screen with an other listview, that will display an other screen when the user will select an item etc.

所以,我知道,在标签活动不便于管理,但我真的认为我需要这个解决方案。事实上,每个屏幕必须包含一个向后按钮,这将返回到previous屏幕,用previous状态(在列表中的相同位置)。

So I knew that activities in tabs are not easy to manage, but I really think that I needed this solution. Indeed, each screen must contain a back button, which will return to the previous screen, with the previous state (the same position in the list).

要启动选项卡里面的新的活动,我这里使用的描述的技术http://gamma-point.com/content/android-how-have-multiple-activities-under-single-tab-tabactivity

To start new activities inside the tabs, I used the technique described here http://gamma-point.com/content/android-how-have-multiple-activities-under-single-tab-tabactivity

它的工作原理主要是好,但我遇到一个问题,回到previous活动。我目前的解决方案包括在像它本网站所描述开始previous活动,但没有任何标志。

It works mostly well, but I encounter a problem to go back to the previous activities. My solution at the moment consists in starting the previous activity like it's described on this website, but without any flag.

因此​​,这里有我的两个现实的问题:

So here are my two real problems:

当我试图回到选项卡的第一和主要活动,似乎是在创建新实例,即使我用标志 Intent.FLAG_ACTIVITY_CLEAR_TOP 。所以,当我做这个活动和下一个之间的几个往返,我获得StackErrorOverFlow。

When I try to go back to the first and main activity of the tab, it seems that a new instance is created, even if I use the flag Intent.FLAG_ACTIVITY_CLEAR_TOP. So when I do several roundtrips between this activity and the next one, i obtain a StackErrorOverFlow.

由于该活动是由型动物活动的访问,我把所有的时间记住父母的活动,给他们的意图。这是非常沉重时,我有5个或6个屏幕继承,我一定要记住盛大隆重的父母,如果该活动......我真的AP preciate如果我只是能够调用由localActivityManager开始了最后的活动。

Because the activities are accessible from differents activities, I have to memorize the parents activities all the time, by giving them in the intents. It's really heavy when I have a succession of 5 or 6 screens, I have to memorize the grand grand parent if the activity... I really appreciate if I just could call the last Activity started by the localActivityManager.

感谢您的帮助, 如果我没有理解,请让我知道!

Thanks for your help, and if I'm not understandable, please, let me know !

推荐答案

好了,该解决方案(在网站上面给出),是这样的:

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 ); 
  }
});

和拿出我来自的ActivityGroup主要activitity。你可以在这里看到了答案:http://gamma-point.com/content/android-how-have-multiple-activities-under-single-tab-tabactivity#comment-4

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

 
精彩推荐
图片推荐