package com.example.test1; import android.os.Bundle; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; public class Fragment extends FragmentActivity { private String tilte[]={"秀珍","小河","厘普","张田中","多栋"}; private String settingText[][]={{"秀珍"," 秀珍是微博漫画作者暹罗厘普创作的漫画人物之一。秀珍是一个捉摸不透、精神不稳定的粉红兔子。爱吃麦当劳,喜欢人类,最怕暹罗厘普说它罗圈腿。"}, {"小河"," 小河是微博漫画作者暹罗厘普创作的漫画人物之一。小河是一个嘴巴大大、脚掌大大的鹈鹕。小河见到张田中的第一眼差点把它当小零食吃掉,说话只会“呱呱呱”,喜欢啃秀珍的脑袋,可能是重庆鹈鹕吧。"}, {"厘普"," 厘普是微博漫画作者暹罗厘普创作的漫画人物之一。厘普是一个阴阳怪气、爱打退堂鼓的暹罗猫猫。爱拉屎,爱耍酷,跟多栋是猫朋狗友,两个人天天干些奇奇怪怪的事。"}, {"张田中"," 张田中是微博漫画作者暹罗厘普创作的漫画人物之一。张田中是一个从超市死里逃生的胡萝卜,田中有些内向,只跟秀珍玩。咱也不知道一个胡萝卜怎么喜欢和兔子玩,hhhhhh……"}, {"多栋"," 多栋是微博漫画作者暹罗厘普创作的漫画人物之一。多栋是一个下三白、爱摆烂的比格犬。爱吃肯德基,爱吃罐罐的,喜欢和厘普打架。"}}; //获取标题数组的方法 public String[] getTilte(){ return tilte; } //获取标题和内容 public String[][] getSettingText(){ return settingText; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment); //创建Fragment SetTitleFragment titleFragment=new SetTitleFragment(); SetContentFragment setcontentFragment=new SetContentFragment(); //获取事物 FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction transaction = fragmentManager.beginTransaction(); //添加Fragment transaction.replace(R.id.settitle,titleFragment); transaction.replace(R.id.setcontent,setcontentFragment); //提交事物 transaction.commit(); } }