【问题标题】:How do I edit content, in a template of android application, in eclipse?如何在 Eclipse 中编辑 Android 应用程序模板中的内容?
【发布时间】:2013-11-23 02:57:11
【问题描述】:

我已经尝试在 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:

谢谢你帮助我...

【问题讨论】:

  • 你有没有试过研究这个?您应该在发布问题之前这样做。
  • 为了记录,您“更改标签名称”只是更改标签名称所引用的 String's 名称。因此,将字符串命名为 title_section1 并且您正在更改该字符串名称。好吧,选项卡名称设置为 title_section1 是什么,这就是它的工作原理。您添加更多字符串只是添加更多字符串。就这么简单。它不会为您创建布局。
  • @mikeaworski 我试过了,但在任何地方都找不到答案...:/
  • 很公平。不过,在 Google 上找到答案可能并不难。反正我给了你+1。希望有人能帮助你。

标签: android eclipse swipeview


【解决方案1】:

您应该通过编辑预先生成的标签来添加新标签

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 布局文件):

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;
        }
    }

【讨论】:

    猜你喜欢
    • 2012-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-17
    • 1970-01-01
    • 1970-01-01
    • 2020-09-10
    相关资源
    最近更新 更多