Please explain ArticleListFragment
and ArticleReaderFragmet
as they are in this code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment android:name="com.example.news.ArticleListFragment"
android:id="@+id/list"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent" />
<fragment android:name="com.example.news.ArticleReaderFragment"
android:id="@+id/viewer"
android:layout_weight="2"
android:layout_width="0dp"
android:layout_height="match_parent" />
</LinearLayout>
I don't know what they refer to? Is it either the Fragment class (or its subclass) that use in source code or XML files for layout?
If they are XML files where must they be located?
Accessing in a Fragment Inside a fragment, you can get a reference to the FragmentManager that manages the fragment's children through getChildFragmentManager() . If you need to access its host FragmentManager , you can use getParentFragmentManager() .
The ArticleListFragment and ArticleReaderFragment are names of classes that contain java code for these fragments.
As it was mentioned before you can have your fragment inside containing activity, but it is not a good practice to do so.
For a good example try to create "Blank Activity with Fragment" using Android Studio wizard. It will create an activity class and a fragment class along with 2 XML files for activity and fragment respectively.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With