将一个片段及其更新链接到另一个片段中

时间:2019-05-01 15:33:31

标签: android android-fragments

The Problem

我有 2个片段,我使用ViewPager进行导航,如您在图中看到的,用户首先遇到片段1在EditText中添加了值,然后进行导航到片段2 。在片段2内我希望片段1以用户添加的值显示,但是我添加并链接到片段1类的片段xml布局显示的布局没有用户添加的值。

在片段2 XML中

     <fragment
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
<!--Linking Fragment 1 class -->
                    class="com.example.acer.patinternational.Child"
                    android:name="com.example.acer.patinternational.Child"
                    android:tag="@string/app_name"
                    android:layout_gravity="center"
                    android:id="@+id/f1"
<!--Linking Fragment 1 Layout-->
                    tools:layout="@layout/childinfo" />

这不是关于如何在另一个内部放置一个Fragment,而是要在另一个内部获取一个fragment context。

0 个答案:

没有答案