第一步:first_fragment.xml:
作为fragment的布局,使用一个textview。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/txt_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="文本"
android:textSize="20sp"/>
</LinearLayout>
第二步:FirstFragment.java:
用来设置fragment中的参数:
@SuppressLint("ValidFragment")
public class FirstFragment extends Fragment {
private String context;//用于设置textview的值
private TextView m