Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9223551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:06:13+00:00 2026-06-18T04:06:13+00:00

Hey I’m quite new to creating android apps. I want to create three Tabs

  • 0

Hey I’m quite new to creating android apps. I want to create three Tabs in the Actionbar. I’ve already done this by creating them using New->Android Activity-> Navigation with Swipe and Tabs.

So that’s my code of the MainActivity (used one of android.com’s tutorials):

 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) {
            // Create a new TextView and set its text to the fragment's section
            // number argument value.
            int current_section = getArguments().getInt(ARG_SECTION_NUMBER);

            switch(current_section){
            case 1:
            {

                EditText element1 = new EditText(getActivity());
                element1.setHint(R.string.edit_text_hint);
                element1.setGravity(Gravity.TOP);
                element1.setPadding(40,40,40,0);
                element1.setSingleLine();

                TextView textView = new TextView(getActivity());
                textView.setGravity(Gravity.CENTER);
                textView.setText("Search");


                return element1;
            }
            case 2:
            {
                TextView textView = new TextView(getActivity());
                textView.setGravity(Gravity.CENTER);
                textView.setText("User Account");
                return textView;
            }
            case 3:
            {
                TextView textView = new TextView(getActivity());
                textView.setGravity(Gravity.CENTER);
                textView.setText("Last Updated");
                return textView;
            }
            }
            TextView textView1 = new TextView(getActivity());
            textView1.setGravity(Gravity.CENTER);
//          textView.setText(Integer.toString(getArguments().getInt(
//                  ARG_SECTION_NUMBER)));
            return textView1;
        }
    }

So in each of the three Tabs there is a different Item display, unfortunatelly it is only possible to display one – and not more. I think it’s quite an easy question but I’m just not figuring out how this could work.
Hope you can help me with this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:06:14+00:00Added an answer on June 18, 2026 at 4:06 am

    In the tutorial, you are returning a textview. Try to add the textview to a Layout, and return the layout.

    I think what you want is use different fragments for different tabs. You can then specify your layout and other code in the fragment itself, instead of building one BIG fragment with a switch case.

    For every Fragment you create a new class. This Fragment can be added to a TabBarListener.

    In the onCreateView of Fragment, you can create your layout programmatically by adding objects to the view parameter. You can also use the inflator to inflate your XML layout.

    I created a sample project, were 1 Fragment view is inflated, the other is created programmatically:

    here

    If you read the android documentation it will be much more clear. I think they even have a sample code project.

    Actiobar, the tab sections

    More info about fragments

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey Guys If I do this in mono touch: var alert = new UIAlertView
Hey guys so I'm a bit new to Android programming and I have an
Hey guys I'm working with this forum, I want to hide the categories list,
Hey! I am trying to get ant installed and actually already did following this
Hey guys this is my html code: <div class=nakupy> <li class=icn_kategorie><a href=#>Nákupy</a> <div class=sub_menu>
*Hey , I have finished developing my app In my iphone apps I have
Hey I just started dabbling with android programming, and from my short period of
hey guys having this really simple problem but cant seem to figure out have
Hey guys I wanted to create a JScrollPane but it won't work... and I
Hey i have made a countdown, but what i want is a div that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.