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

  • Home
  • SEARCH
  • 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 9054449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:41:40+00:00 2026-06-16T13:41:40+00:00

This is my 1st question so i will try to b as precise as

  • 0

This is my 1st question so i will try to b as precise as possible. I am trying the create an application using Fragment Activity, Fragment List and View Pager. When the activity loads by default the fragment list should be shown to the left and view pager is shown to the right (the detail view). When i click one of the fragment list buttons i want to load a webview in the detail view (right side).

I have implemented the Fragment Activity with Fragment List. Now how to add View Pager to this so that it shows up when the application loads up ..

    public class MainActivity extends FragmentActivity implements McDonaldsListener {

  @Override
 public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

McDonaldsFragment countries
  =(McDonaldsFragment)getSupportFragmentManager()
                        .findFragmentById(R.id.countries);

countries.setCountryListener(this);

Fragment f=getSupportFragmentManager().findFragmentById(R.id.details);


  countries.enablePersistentSelection();

  }

 @Override
  public void onCountrySelected(McDonalds c) {
String url=getString(c.url);


  ((DetailsFragment)getSupportFragmentManager()
                        .findFragmentById(R.id.details))
                        .loadUrl(url);                            


  }
 }

There are other supporting classes which if there is need i will post it.

Hope some one can suggest me some solutions.

Edit:
This is what i tried to implement but dosent work….Gives Instantiation Exception 🙁

public class ViewPagerExample extends android.support.v4.app.FragmentActivity        implements McDonaldsListener {
private MyAdapter mAdapter;
private ViewPager mPager;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mAdapter = new MyAdapter(getSupportFragmentManager());

    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mAdapter);


    McDonaldsFragment mc
    =(McDonaldsFragment)getSupportFragmentManager()
                          .findFragmentById(R.id.countries);

  mc.setCountryListener(this);

  Fragment f=getSupportFragmentManager().findFragmentById(R.id.details);

    mc.enablePersistentSelection();
}

public void onCountrySelected(McDonalds c) {
  String url=getString(c.url);


    ((DetailsFragment)getSupportFragmentManager()
                          .findFragmentById(R.id.details))
                          .loadUrl(url);                            


}

public static class MyAdapter extends FragmentPagerAdapter {
    public MyAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public int getCount() {
        return 3;
    }

    @Override
    public Fragment getItem(int position) {
        switch (position) {
        case 0:
            return new DetailFragment();
        case 1:
            return new ImageFragment(R.drawable.ic_launcher);
        case 2:
            return new ImageFragment(R.drawable.ic_launcher);

        default:
            return null;
        }
    }
  }
 }
  • 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-16T13:41:41+00:00Added an answer on June 16, 2026 at 1:41 pm

    lets try this peter kuterna view pager
    http://blog.peterkuterna.net/2011/09/viewpager-meets-swipey-tabs.html

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

Sidebar

Related Questions

This is similar to a recent question. I will be maintaining sorted a list
This question is quite specific to the code i'm trying to use, 1st ill
Using the method described in this question , I can get a list of
I have 1st popup, and this 1st popup opens 2nd popup Code: <view-state id=paneMaintenance
This is the 1st time I am using stackoverflow, I usually find answers to
Consider this query to group a list of students by the 1st letter of
I will try to describe it as simple as possible. We have SqlConnection and
Possible Duplicate: Hide facebook app from search Okay, I know that this question was
This is a question for a SQL specialist! I'm using SQL SERVER 2008 R2
This is probably a ridiculously simple question. I am trying to show a map,

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.