Note that there are some explanatory texts on larger screens.

plurals
  1. POViewPager along with FragmentList in Fragment Activity
    primarykey
    data
    text
    <p>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).</p> <p>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 ..</p> <pre><code> 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); } } </code></pre> <p>There are other supporting classes which if there is need i will post it.</p> <p>Hope some one can suggest me some solutions.</p> <p>Edit: This is what i tried to implement but dosent work....Gives Instantiation Exception :(</p> <pre><code>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; } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload