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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:28:19+00:00 2026-06-04T09:28:19+00:00

I need to create four different layouts, each one to a page of ViewPagerIndicator.

  • 0

I need to create four different layouts, each one to a page of ViewPagerIndicator.
How can I do this? The ViewPagerIndicator is already working, but I’m using the sample from http://viewpagerindicator.com and there is created a simple TextView for all pages.

See the sample (TestFragment.java):

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

    TextView text = new TextView(getActivity());
    text.setGravity(Gravity.CENTER);
    text.setText(mContent);
    text.setTextSize(20 * getResources().getDisplayMetrics().density);
    text.setPadding(20, 20, 20, 20);

    LinearLayout layout = new LinearLayout(getActivity());
    layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    layout.setGravity(Gravity.CENTER);
    layout.addView(text);

    return layout;
}

I need to identify the current page (position) and refer to a related resource layout (XML). Is it possible?

I also need to ensure that all Views of all pages to be loaded at once only one time when I create the activity, allowing values ​​to be updated later.

I appreciate any help!!
Thanks

  • 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-04T09:28:21+00:00Added an answer on June 4, 2026 at 9:28 am

    I found a simple solution which works for me. Here is what I did.

    TestFragment.class

          public static TestFragment newInstance(String content) {
            TestFragment fragment = new TestFragment();
    //
    //        StringBuilder builder = new StringBuilder();
    //        for (int i = 0; i < 20; i++) {
    //            builder.append(content).append(" ");
    //        }
    //        builder.deleteCharAt(builder.length() - 1);
            fragment.mContent = content;
    
            return fragment;
        }
    

    Comment out the for loop here. Just get the mContent which we are going to use as a Flag.

    Now in your onCreateView() change it as follows,

       @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    //        TextView text = new TextView(getActivity());
    //        text.setGravity(Gravity.CENTER);
    //        text.setText(mContent);
    //        text.setTextSize(20 * getResources().getDisplayMetrics().density);
    //        text.setPadding(20, 20, 20, 20);
    //
    //        LinearLayout layout = new LinearLayout(getActivity());
    //        layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    //        layout.setGravity(Gravity.CENTER);
    //        layout.addView(text);
            Log.i("mContent",mContent);
            View view=null;
            if(mContent.equalsIgnoreCase("title1"))
            {
                view = inflater.inflate(R.layout.one, container, false);
    
            }
            else if(mContent.equalsIgnoreCase("title2"))
            {
                view = inflater.inflate(R.layout.two, container, false);
            }
            else if(mContent.equalsIgnoreCase("title3"))
            {
                view = inflater.inflate(R.layout.three, container, false);
            }
            return view;
    
        }
    

    That is all it takes. Now you will be able to inflate your views based on the Title name which we have used as the flag.

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

Sidebar

Related Questions

I need create clone repository. but I do not know where can I get
I need create a document word with Java. And I ask, how can I
Need to create a custom DNS name server using C which will check against
I need to create a WP site which will have multiple subjects. Each subject
I need to create a MySQL query that generates 4 rows for each row
I need to create a home screen (menu) with four to six items arranged
I need to create a WAV file in PHP that consists of four repetitions
I create different buttons dynamically like this: for (int toShow = 1; toShow <=
I've created a UITableView that is entirely composed of four different groupings. Each section/group
I have a DataGridView with four Columns and need to crate a multiline string

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.