将活动设置为swipey标签中的内容?

时间:2012-01-28 11:36:29

标签: android android-activity android-fragments android-viewpager

所以我找到了this  Swipey标签实施的一个很好的例子(像Android市场中的标签UI)。

是否可以将活动设置为其内容?是否有类似“活动容器”的东西,我可以在XML中设置并在其中放置一个活动?所以基本上我想在ViewPager中将多个活动设置为内容。如果有人对此问题有一些好的解决方案,请告诉我。

1 个答案:

答案 0 :(得分:1)

根据我的理解,您所寻找的是fragments,但它们仅适用于Android SDK 3.0及更高版本。


编辑:我的印象是Activity无法放入View。显然我错了。 Here是一个关于使用LocalActivityManager将活动放置在容器视图中的旧主题。

如果线程消失,最有用的帖子包含此代码片段:

void createInnerActivity(ViewGroup container, Class<?> activityClass) 
{ 
    if (container.getChildCount() != 0) { 
        container.removeViewAt(0); 
    } 
    final Intent intent = new Intent(this, activityClass); 
    final Window window = 
        getLocalActivityManager().startActivity(activityClass.toString(), 
                                                intent); 
    container.addView(
        window.getDecorView(),
        new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, 
                                   ViewGroup.LayoutParams.FILL_PARENT)); 
}