ham*_*d_c 11 android android-fragments
请解释一下ArticleListFragment,ArticleReaderFragmet因为它们在这段代码中:
<?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>
Run Code Online (Sandbox Code Playgroud)
我不知道他们指的是什么?它是在源代码中使用的Fragment类(或其子类)还是用于布局的XML文件?
如果它们是XML文件,它们必须位于哪里?
Iva*_*n V 10
ArticleListFragment和ArticleReaderFragment是包含这些片段的Java代码的类的名称.
正如前面提到的,你可以让你的片段包含活动,但这样做并不是一个好习惯.
举个好例子,尝试使用Android Studio向导创建"带片段的空白活动".它将分别为活动和片段创建一个活动类和一个片段类以及2个XML文件.
<fragment android:name="com.example.app.myFragment"/>
Run Code Online (Sandbox Code Playgroud)
name属性用于指定用于创建View层次结构的Fragment类-在本例中为myFragment.java。
| 归档时间: |
|
| 查看次数: |
9275 次 |
| 最近记录: |