Note that there are some explanatory texts on larger screens.

plurals
  1. POFragmentPagerAdapter using ViewPagerIndicator not working
    primarykey
    data
    text
    <p>I have decided for remaking UI of my app by using ViewPagerIndicator and TitlePageIndicator, but I have following problems: </p> <p>1) Fragments that are for each page are not displayed.</p> <p>2) Swipe betwen two pages does not work.</p> <p>I am using ActionBarSherlock as I did with tabs.</p> <p>I have not changed anything in Fragmens since it has workrd fine when I was using tabs and I have written following code:</p> <pre><code>public class CustomFragmentAdapter extends FragmentPagerAdapter { private final String[] TITLES = new String[] { "General", "Companies", "Discounts" }; public final int NUM_TITLES = TITLES.length; public CustomFragmentAdapter(FragmentManager fm) { super(fm); } @Override public Fragment getItem(int position) { Log.v("POSITION", "position: "+position); switch (position) { case 0: return new General(); case 1: return new Companies(); case 2: return new Discounts(); } return null; } @Override public int getCount() { return NUM_TITLES; } @Override public CharSequence getPageTitle(int position) { return TITLES[position % NUM_TITLES].toUpperCase(); } } </code></pre> <p>and</p> <pre><code>mViewPager = (ViewPager)findViewById(R.id.pager); mViewPager.setAdapter(new CustomFragmentAdapter(getSupportFragmentManager())); TitlePageIndicator indicator = (TitlePageIndicator) findViewById(R.id.indicator); indicator.setViewPager(mViewPager); indicator.setCurrentItem(0); </code></pre> <p>and my XML</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/main" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;com.viewpagerindicator.TitlePageIndicator android:id="@+id/indicator" android:layout_height="wrap_content" android:layout_width="match_parent" /&gt; &lt;android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" /&gt; </code></pre> <p></p> <p>As I have seen most of the tutorials and examples are quiet similar to my code, but I still can't make it work. I have tried almost everything. It was also not working when I have put there some dummy fragments with just some TextView. I also have tried to remove ViewPagerIndicator and try only ViewPager, but it was not working for me.</p> <p>I am probably missing something, but I can't find it. Thank you very much in advance for your advices.</p>
    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.
 

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