3

I have tried create a Android app in Eclipse for a while.. And I used the "BlankActivity" template with "Navigation Type: Swipe Views + Title Strip" option...

I can change the tab's name by editing the file "\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>

But i dont know how add more tabs/sections (isn't just add another line below these, as I thought), either how edit the content of the sections (I looked every file in the project, and i couldn't find where should I edit)... D:

Thanks for helping me...

  • Did you try researching this at all? You should do that before you post a question. – Michael Yaworski Nov 23 '13 at 03:03
  • For the record, you "changing the tabs name" is just changing the **String's** name that the tabs name is referenced to. So the String name it title_section1 and you're changing that String name. Well the tab name is set to be whatever title_section1 is, so that's how that works. You adding more Strings is just adding more Strings. It's as simple as that. It doesn't create a layout for you. – Michael Yaworski Nov 23 '13 at 03:06
  • @mikeyaworski I tried, but couldn't find the answer anywhere... :/ – user3023946 Nov 23 '13 at 03:06
  • Fair enough. it's probably not that hard to find an answer on Google though. I gave you +1 anyways. Hope someone helps you out. – Michael Yaworski Nov 23 '13 at 03:07

1 Answers1

0

You should add your new tabs by editing pre-generated

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 is in fact a fragment you want to view by selecting specific tab, so you should define your own fragments (with their respective layout files in XML) according to this pre-generated example:

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;
        }
    }
BartekK
  • 71
  • 4