我尝试在Eclipse中创建Android应用程序一段时间..我使用“BlankActivity”模板和“导航类型:滑动视图+标题条”选项......
我可以通过编辑文件“\ res \ values \ strings.xml”...
来更改选项卡的名称<string name="title_section1">Section 1</string>
<string name="title_section2">Section 2</string>
<string name="title_section3">Section 3</string>
但是我不知道如何添加更多标签/部分(不只是在这些下面添加另一行,正如我所想的那样),或者如何编辑部分的内容(我查看了项目中的每个文件,我无法'找到我应该在哪里编辑)... D:
感谢您帮助我......
答案 0 :(得分:0)
您应该通过编辑预先生成的
来添加新标签public Fragment getItem(int position) {
// getItem is called to instantiate the fragment for the given page.
// Return a DummySectionFragment (defined as a static inner class
// below) with the page number as its lone argument.
Fragment fragment = new DummySectionFragment();
Bundle args = new Bundle();
args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, position + 1);
fragment.setArguments(args);
return fragment;
}
DummyScetionFragment 实际上是您要通过选择特定选项卡来查看的片段,因此您应该根据此预生成的示例定义您自己的片段(以及它们各自的XML布局文件): / p>
public static class DummySectionFragment extends Fragment {
/**
* The fragment argument representing the section number for this
* fragment.
*/
public static final String ARG_SECTION_NUMBER = "section_number";
public DummySectionFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main_dummy,
container, false);
TextView dummyTextView = (TextView) rootView
.findViewById(R.id.section_label);
dummyTextView.setText(Integer.toString(getArguments().getInt(
ARG_SECTION_NUMBER)));
return rootView;
}
}