Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 更新选项卡式活动片段中TextView的文本_Android_Android Fragments_Textview - Fatal编程技术网

Android 更新选项卡式活动片段中TextView的文本

Android 更新选项卡式活动片段中TextView的文本,android,android-fragments,textview,Android,Android Fragments,Textview,我有一个选项卡式活动,其中有两个片段。在一个片段中有一些文本视图。但是我不能更新这些文本视图的文本。我尝试了很多方法。这是代码 public static class Holder extends Fragment{ private static final String ARG_SECTION_NUMBER1 = "section_number"; public Holder(){ } TextView Name, Age, Medicine, Doc

我有一个选项卡式活动,其中有两个片段。在一个片段中有一些文本视图。但是我不能更新这些文本视图的文本。我尝试了很多方法。这是代码

    public static class Holder extends Fragment{
    private static final String ARG_SECTION_NUMBER1 = "section_number";
    public Holder(){

    }
    TextView Name, Age, Medicine, Doctor, CareTaker;

    public static Holder newInstance(int sectionNumber){
        Holder fragment1 = new Holder();
        Bundle args1 = new Bundle();
        args1.putInt(ARG_SECTION_NUMBER1,sectionNumber);
        fragment1.setArguments(args1);
        return fragment1;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View rootView = inflater.inflate(R.layout.profile,container,false);
        TextView Name = (TextView) rootView.findViewById(R.id.fName);
        Name.setText("No Name");
        return rootView;
    }

我已经给了这些文本视图一些来自XML的预定义值。

使用
onTabSelected
回调,获取片段实例,然后将其设置为android的新实例,您能详细说明吗?