用单个片段替换ViewPager与android.R.id.content的等价物是什么?

用单个片段替换ViewPager与android.R.id.content的等价物是什么?,android,android-fragments,Android,Android Fragments,通过定期活动,您可以使用 // Display the fragment as the main content. getFragmentManager().beginTransaction() .replace(android.R.id.content, new SettingsFragment()) .commit(); 用另一个片段替换您的主要内容。在Eclipse中使用默认的可滑动选项卡活动,这只是将您的新片段覆盖在其他片段

通过定期活动,您可以使用

// Display the fragment as the main content.
     getFragmentManager().beginTransaction()
             .replace(android.R.id.content, new SettingsFragment())
             .commit();

用另一个片段替换您的主要内容。在Eclipse中使用默认的可滑动选项卡活动,这只是将您的新片段覆盖在其他片段之上。我能否以某种方式获取整个ViewPager的id,并将其替换为android.R.id.content?我想用我的新片段替换所有选项卡。

通常片段在FrameLayout中膨胀 例如:fragment_layout.xml

<FrameLayout android:id"@+id/framelayout" 
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
}

我们可以使用Activity中的replace()方法将任何片段放入此内容框架布局中:

getFragmentManager().beginTransaction()
             .replace(R.id.framelayout, new NewFragment())
             .commit();

这很有道理,我很肯定这是正确的答案。它实际上在默认的Eclipse可滑动选项卡活动中不起作用(新片段不会显示),但我认为这可能是由于。我现在没有时间处理这个问题。
getFragmentManager().beginTransaction()
             .replace(R.id.framelayout, new NewFragment())
             .commit();