【发布时间】:2017-04-16 22:12:38
【问题描述】:
我有一个片段,实际上你有 3 个页面,你可以用它来滑动。 在每个页面上,您都有一个默认字符串,例如“Hello World from section: %1$d”,它保存在字符串中。 xml"
片段java类方法如下:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_generaldiscription, container, false);
TextView textView = (TextView) rootView.findViewById(R.id.section_label);
textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER)));
textView.setText("test"); // testing purposes
return rootView;
}
}
我的问题是:我不希望每个页面都有相同的文本。第 1 节有 "Hello world from section: 1" ,第 2 节有 "Hello world from section: 2"
我希望第 1 部分有一个不同的字符串,例如“你好,这是你片段的第 1 部分”。如何处理片段中的不同部分以显示不同的字符串?
谢谢。
【问题讨论】: