建fragment的时候图省事直接用的list fragment,切换用的是viewpager2,混合起来的结果就是在网上找不到教程。
除了使用之外还有一个更麻烦的刷新问题,这个在下一篇写。
首先listfragmenet会自动建立一个listfragment.xml和一个listfragment_list.xml
大概长这样
list.xml里不用动,至少我暂时没发现有需要动的地方
xml里面就是表项的布局,我的加了一点点东西,整体基本没动
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/light_blue"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/lovedegree"
android:src="@drawable/mylover_1"
android:layout_margin="13dp"/>
<TextView
android:id="@+id/item_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin"
android:textAppearance="?attr/textAppearanceListItem" />
<TextView
android:id="@+id/content"
android