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 8765727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:21:40+00:00 2026-06-13T16:21:40+00:00

How can I know that which tab is active in my public View onCreateView(LayoutInflater

  • 0

How can I know that which tab is active in my

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) function???

Following code is working for just fist navigation but after that in every tab it show last layout.

public final class RobozoxFragment extends Fragment {
private static final String KEY_CONTENT = "RobozoxFragment:Content";
private static int currentPosition = 100;
public static RobozoxFragment newInstance(String content,int position) {
    currentPosition = position;
    RobozoxFragment fragment = new RobozoxFragment();
    StringBuilder builder = new StringBuilder();
    for (int i = 0; i < 20; i++) {
        builder.append(content).append(" ");
    }
    builder.deleteCharAt(builder.length() - 1);
    fragment.mContent = builder.toString();
    return fragment;
}
@Override

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View myFragmentView;

    if(currentPosition == 1){
        myFragmentView = inflater.inflate(R.layout.first, container, false);
    }else if(currentPosition == 2){
        myFragmentView = inflater.inflate(R.layout.second, container, false);
    }else if(currentPosition == 3){

        myFragmentView = inflater.inflate(R.layout.third, container, false);
    }else if(currentPosition == 4){
        myFragmentView = inflater.inflate(R.layout.fourth, container, false);
    }else if(currentPosition ==5){
        myFragmentView = inflater.inflate(R.layout.fifth, container, false);
    }else{
        myFragmentView = inflater.inflate(R.layout.activity_main, container, false);
    }
    return myFragmentView;
}

I think problem is in onCreateView function where I am unable to get the active tab location.

How can i get this thing done.??

  • 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-13T16:21:41+00:00Added an answer on June 13, 2026 at 4:21 pm

    Got the Solution 🙂
    Get the Current Position By Using Bundle and Passing Arguments. Sample Code Below..

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView;
        Bundle args = getArguments();
        int currentView = args.getInt(Constants.ARG_SECTION_NUMBER)-2;
    
        if(currentView == 0){
            rootView = inflater.inflate(R.layout.lay1, container, false);
        }else if(currentView == 1){
            rootView = inflater.inflate(R.layout.lay2, container, false);
        }else {
            rootView = inflater.inflate(R.layout.activity_main, container, false);
        }
    
        return rootView;
    }
    
    
    @Override
    public Fragment getItem(int i) {
        switch (i) {
        case 0:
            // The first section of the app is the most interesting -- it offers
            // a launchpad into the other demonstrations in this example
            // application.
            return new LaunchpadSectionFragment();
    
        default:
            // The other sections of the app are dummy placeholders.
            Fragment fragment = new RobozoxSectionFragment();
            Bundle args = new Bundle();
            args.putInt(Constants.ARG_SECTION_NUMBER, i + 1);
            fragment.setArguments(args);
            return fragment;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just want to know that can i make an application which have some
I know that a submit button in HTML can submit a form which opens
As title says, i know that new throws an exception which can be caught,
I know that can't use left join in indexed view. but I don't understand
How can I know that my iPhone is connected to the Apple Push Notification
How can we know that a site is a Sharepoint Site?
I have code that uses jquery.slideup and jquery.slidedown How can i know that div
web.config: <customErrors mode=On defaultRedirect=~/Foo.aspx /> When Foo.aspx.cs is running, how can I know that
I know that can co-exists with web form no problem as Hanselman mention here
I want to know that can mouse click event detects colors or even strings.

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.