你可以通过对象组合生成它。起初我不知道如何让活动时间,并将其添加到布局,但后来我发现了LocalActivityManager,让你可以嵌入其他活动为您的视图。请注意,由于API级别11.在这里任何情况下,此类已废弃的嵌入其他活动需要扩展为View
步骤:
下查看活动是我的测试代码,我在我的活动范围内尝试
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Create local activity manager so that I could start my activity
LocalActivityManager localActivityManager = new LocalActivityManager(this, true);
// dispatch the onCreate from this manager
localActivityManager.dispatchCreate(savedInstanceState);
// layout to hold the activity, optionally this could be set through XML file
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
this.addContentView(layout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT));
// start the activity which is in this example is an extension of a TabActivity
Intent tabIntent = new Intent(this, DummyTabActivity.class);
Window tabWindow = localActivityManager.startActivity("tabView", tabIntent);
View tabView = tabWindow.getDecorView();
// start the activity that extends MapActivity
Intent mapIntent = new Intent(this, DummyMapView.class);
Window mapViewWindow = localActivityManager.startActivity("mapView", mapIntent);
View mapView = mapViewWindow.getDecorView();
// dispatch resume to the Activities
localActivityManager.dispatchResume();
// add to the tabView, optionally you could use other layout as well
layout.addView(tabView);
// add to the mapView, optionally you could use other layout as well
layout.addView(mapView);
}
我的有限实验表明,通过上述方法的对象组合将实现您正在尝试做的事情。话虽如此,我不确定这种方法有多普遍。没有你的问题,我可能不会去寻找上述方法,但你的用例很有趣,可能适用于将来的使用。我会研究片段,看看我是否可以对它做同样的事情,并在适用的情况下更新我的答案。
你没有明白。我的问题是如何使用需要扩展课程的两个“并排”控制器。我知道我可以把MapView里面的TabView“如果”我想我的MapView“内部”MapView –
你是对的,我不明白这个问题(与刚刚回答的其他人一样)。也许你可以澄清这个问题?你问这个问题的方式似乎在问如何一起使用TabView和MapView。根据你的评论,我猜你是在问如何使用多个控件,而这些控件依赖于扩展其他类? – momo
我刚刚看到你的图:),现在事情更清晰。看起来不像有明显的方法来做到这一点(在Android中)。让我检查并回复你。 – momo