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的新实例,您能详细说明吗?