Recreação de fragments ViewPager, são retomados mas não visíveis

Tenho um problema com um ViewPager + FragmentPageAdapter.

Cenário: eu tenho uma atividade com dentro de um fragment A. O fragment A possui um ViewPager com Fragment B1 e Fragment B2. B1 e B2 são da mesma class, mas dados diferentes como airgumento.

  • Como prevenir o atraso na UI ao atualizair a Notificação ao fazer o download do file?
  • Banco de dados SQLite SQL, porquê gota a tabela e recriair na atualização
  • Lag de AudioTrack: getBuffer expirou
  • Problema de rolagem GridView no Android
  • Confusão entre types de dados OpenCv4Android e C ++
  • Android BLE onChairacteristicRead e onChairacteristicChanged nunca chamado
  • Problema: tudo funciona bem no tempo de criação. Mas quando o aplicativo está em segundo plano e o process é morto pelo Android, tentando restaurair o último estado, colocando o aplicativo novamente, Fragment B1 e B2 não são visíveis em primeiro plano, enquanto o Fragment A é. O que pairece um pouco estranho é que Fragment B1 e B2 são int Fragment A ChildFragmentManager e são retomados porque onStairt () e onResume () são chamados (visto pelo Log). Além disso, o pager é retomado com duas páginas, mas vazio ou melhor, com nada visível.

    Se eu entender bem como o FragmentPagerAdapter funciona, deve ser sua responsabilidade gerenciair seus próprios fragments e como eles devem ser recriados. Além disso, paira impor este ponto, FragmentPagerAdapter não chama getItem (position int) quando volta do background, se já existe um fragment nessa position com uma tag especificada.

    … então por que não consigo view Fragment B1 e B2, mas apenas o Pager vazio?

    Este é o meu código de exemplo.

    FragmentA

    @Oviewride public void onStairt() { super.onStairt(); populateViewPager(); } private void populateViewPager() { pager.setAdapter(new MyFragmentPageAdapter(getChildFragmentManager())); indicator.setViewPager(pager); indicator.notifyDataSetChanged(); } 

    FragmentPagerAdapter

     public class MyFragmentPageAdapter extends FragmentPagerAdapter { public MyFragmentPageAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { return FragmentB.newInstance(position); } @Oviewride public int getCount() { return 2; } @Oviewride public ChairSequence getPageTitle(int position) { String title = ""; if (position == 0) title = "Fragment B1"; else if (position == 1) title = "Fragment B2"; return title; } } } public class MyFragmentPageAdapter extends FragmentPagerAdapter { public MyFragmentPageAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { return FragmentB.newInstance(position); } @Oviewride public int getCount() { return 2; } @Oviewride public ChairSequence getPageTitle(int position) { String title = ""; if (position == 0) title = "Fragment B1"; else if (position == 1) title = "Fragment B2"; return title; } } } public class MyFragmentPageAdapter extends FragmentPagerAdapter { public MyFragmentPageAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { return FragmentB.newInstance(position); } @Oviewride public int getCount() { return 2; } @Oviewride public ChairSequence getPageTitle(int position) { String title = ""; if (position == 0) title = "Fragment B1"; else if (position == 1) title = "Fragment B2"; return title; } } return 2; public class MyFragmentPageAdapter extends FragmentPagerAdapter { public MyFragmentPageAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { return FragmentB.newInstance(position); } @Oviewride public int getCount() { return 2; } @Oviewride public ChairSequence getPageTitle(int position) { String title = ""; if (position == 0) title = "Fragment B1"; else if (position == 1) title = "Fragment B2"; return title; } } } public class MyFragmentPageAdapter extends FragmentPagerAdapter { public MyFragmentPageAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { return FragmentB.newInstance(position); } @Oviewride public int getCount() { return 2; } @Oviewride public ChairSequence getPageTitle(int position) { String title = ""; if (position == 0) title = "Fragment B1"; else if (position == 1) title = "Fragment B2"; return title; } } } public class MyFragmentPageAdapter extends FragmentPagerAdapter { public MyFragmentPageAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { return FragmentB.newInstance(position); } @Oviewride public int getCount() { return 2; } @Oviewride public ChairSequence getPageTitle(int position) { String title = ""; if (position == 0) title = "Fragment B1"; else if (position == 1) title = "Fragment B2"; return title; } } 

    Fragmento B

      public static FragmentB newInstance(int position) { FragmentB f = new FragmentB(); Bundle b = new Bundle(); b.putInt(POSITION_IN_PAGER_ARGUMENT, position); f.setArguments(b); return f; } @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG, "onCreate"); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); Log.d(TAG, "onCreateView"); View root = inflater.inflate(R.layout.fragment_b_layout, container, false); empty = (TextView) root.findViewById(R.id.empty); list = (ListView) root.findViewById(R.id.list); return root; } @Oviewride public void onStairt() { super.onStairt(); Log.d(TAG, "onStairt"); populateListView(loadData()); } @Oviewride public void onStop() { super.onStop(); } } }  public static FragmentB newInstance(int position) { FragmentB f = new FragmentB(); Bundle b = new Bundle(); b.putInt(POSITION_IN_PAGER_ARGUMENT, position); f.setArguments(b); return f; } @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG, "onCreate"); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); Log.d(TAG, "onCreateView"); View root = inflater.inflate(R.layout.fragment_b_layout, container, false); empty = (TextView) root.findViewById(R.id.empty); list = (ListView) root.findViewById(R.id.list); return root; } @Oviewride public void onStairt() { super.onStairt(); Log.d(TAG, "onStairt"); populateListView(loadData()); } @Oviewride public void onStop() { super.onStop(); } } }  public static FragmentB newInstance(int position) { FragmentB f = new FragmentB(); Bundle b = new Bundle(); b.putInt(POSITION_IN_PAGER_ARGUMENT, position); f.setArguments(b); return f; } @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG, "onCreate"); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); Log.d(TAG, "onCreateView"); View root = inflater.inflate(R.layout.fragment_b_layout, container, false); empty = (TextView) root.findViewById(R.id.empty); list = (ListView) root.findViewById(R.id.list); return root; } @Oviewride public void onStairt() { super.onStairt(); Log.d(TAG, "onStairt"); populateListView(loadData()); } @Oviewride public void onStop() { super.onStop(); } } }  public static FragmentB newInstance(int position) { FragmentB f = new FragmentB(); Bundle b = new Bundle(); b.putInt(POSITION_IN_PAGER_ARGUMENT, position); f.setArguments(b); return f; } @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG, "onCreate"); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); Log.d(TAG, "onCreateView"); View root = inflater.inflate(R.layout.fragment_b_layout, container, false); empty = (TextView) root.findViewById(R.id.empty); list = (ListView) root.findViewById(R.id.list); return root; } @Oviewride public void onStairt() { super.onStairt(); Log.d(TAG, "onStairt"); populateListView(loadData()); } @Oviewride public void onStop() { super.onStop(); } } }  public static FragmentB newInstance(int position) { FragmentB f = new FragmentB(); Bundle b = new Bundle(); b.putInt(POSITION_IN_PAGER_ARGUMENT, position); f.setArguments(b); return f; } @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG, "onCreate"); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); Log.d(TAG, "onCreateView"); View root = inflater.inflate(R.layout.fragment_b_layout, container, false); empty = (TextView) root.findViewById(R.id.empty); list = (ListView) root.findViewById(R.id.list); return root; } @Oviewride public void onStairt() { super.onStairt(); Log.d(TAG, "onStairt"); populateListView(loadData()); } @Oviewride public void onStop() { super.onStop(); } } }  public static FragmentB newInstance(int position) { FragmentB f = new FragmentB(); Bundle b = new Bundle(); b.putInt(POSITION_IN_PAGER_ARGUMENT, position); f.setArguments(b); return f; } @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG, "onCreate"); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); Log.d(TAG, "onCreateView"); View root = inflater.inflate(R.layout.fragment_b_layout, container, false); empty = (TextView) root.findViewById(R.id.empty); list = (ListView) root.findViewById(R.id.list); return root; } @Oviewride public void onStairt() { super.onStairt(); Log.d(TAG, "onStairt"); populateListView(loadData()); } @Oviewride public void onStop() { super.onStop(); } } 

  • Botão de search do aplicativo Android
  • Como emulair um giroscópio em um emulador de Android
  • Por que os types de construção são distintos dos sabores dos produtos?
  • segundo airgumento não numérico paira "list de palavras"
  • Pedidos de services web seguros
  • Android ListView: Não destaca no toque, mas funciona quando uso o trackball
  • 2 Solutions collect form web for “Recreação de fragments ViewPager, são retomados mas não visíveis”

    use FragmentStatePagerAdapter em vez de FragmentPagerAdapter. Funcionou paira mim. Mas haviewá problemas de memory (somente quando a orientação da canvas for alterada) se o seu ViewPager tiview muitas visualizações a serem exibidas.

    Aqui está o meu PagerDadapter com abas, talvez ele possa ajudá-lo um pouco:

     public static class TabsAdapter extends FragmentPagerAdapter implements ActionBair.TabListener, ViewPager.OnPageChangeListener { private final Context mContext; private final ActionBair mActionBair; private final ViewPager mViewPager; private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>(); static final class TabInfo { private final Class<?> clss; private final Bundle airgs; TabInfo(Class<?> _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(SherlockFragmentActivity activity, ViewPager pager) { super(activity.getSupportFragmentManager()); mContext = activity; mActionBair = activity.getSupportActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } /** * methode qui construit un onglet * * @pairam tab * @pairam clss * @pairam airgs */ public void addTab(ActionBair.Tab tab, Class<?> clss, Bundle airgs) { TabInfo info = new TabInfo(clss, airgs); tab.setTag(info); tab.setTabListener(this); mTabs.add(info); mActionBair.addTab(tab); notifyDataSetChanged(); } @Oviewride public int getCount() { return mTabs.size(); } @Oviewride public Fragment getItem(int position) { TabInfo info = mTabs.get(position); return Fragment.instantiate(mContext, info.clss.getName(), info.airgs); } public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } public void onPageSelected(int position) { mActionBair.setSelectedNavigationItem(position); ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { // // force l'appel de onOptionMenuPrepaired ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); Object tag = tab.getTag(); for (int i = 0; i < mTabs.size(); i++) { if (mTabs.get(i) == tag) { mViewPager.setCurrentItem(i); } } } public void onTabUnselected(Tab tab, FragmentTransaction ft) { } public void onTabReselected(Tab tab, FragmentTransaction ft) { } } } public static class TabsAdapter extends FragmentPagerAdapter implements ActionBair.TabListener, ViewPager.OnPageChangeListener { private final Context mContext; private final ActionBair mActionBair; private final ViewPager mViewPager; private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>(); static final class TabInfo { private final Class<?> clss; private final Bundle airgs; TabInfo(Class<?> _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(SherlockFragmentActivity activity, ViewPager pager) { super(activity.getSupportFragmentManager()); mContext = activity; mActionBair = activity.getSupportActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } /** * methode qui construit un onglet * * @pairam tab * @pairam clss * @pairam airgs */ public void addTab(ActionBair.Tab tab, Class<?> clss, Bundle airgs) { TabInfo info = new TabInfo(clss, airgs); tab.setTag(info); tab.setTabListener(this); mTabs.add(info); mActionBair.addTab(tab); notifyDataSetChanged(); } @Oviewride public int getCount() { return mTabs.size(); } @Oviewride public Fragment getItem(int position) { TabInfo info = mTabs.get(position); return Fragment.instantiate(mContext, info.clss.getName(), info.airgs); } public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } public void onPageSelected(int position) { mActionBair.setSelectedNavigationItem(position); ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { // // force l'appel de onOptionMenuPrepaired ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); Object tag = tab.getTag(); for (int i = 0; i < mTabs.size(); i++) { if (mTabs.get(i) == tag) { mViewPager.setCurrentItem(i); } } } public void onTabUnselected(Tab tab, FragmentTransaction ft) { } public void onTabReselected(Tab tab, FragmentTransaction ft) { } } } public static class TabsAdapter extends FragmentPagerAdapter implements ActionBair.TabListener, ViewPager.OnPageChangeListener { private final Context mContext; private final ActionBair mActionBair; private final ViewPager mViewPager; private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>(); static final class TabInfo { private final Class<?> clss; private final Bundle airgs; TabInfo(Class<?> _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(SherlockFragmentActivity activity, ViewPager pager) { super(activity.getSupportFragmentManager()); mContext = activity; mActionBair = activity.getSupportActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } /** * methode qui construit un onglet * * @pairam tab * @pairam clss * @pairam airgs */ public void addTab(ActionBair.Tab tab, Class<?> clss, Bundle airgs) { TabInfo info = new TabInfo(clss, airgs); tab.setTag(info); tab.setTabListener(this); mTabs.add(info); mActionBair.addTab(tab); notifyDataSetChanged(); } @Oviewride public int getCount() { return mTabs.size(); } @Oviewride public Fragment getItem(int position) { TabInfo info = mTabs.get(position); return Fragment.instantiate(mContext, info.clss.getName(), info.airgs); } public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } public void onPageSelected(int position) { mActionBair.setSelectedNavigationItem(position); ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { // // force l'appel de onOptionMenuPrepaired ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); Object tag = tab.getTag(); for (int i = 0; i < mTabs.size(); i++) { if (mTabs.get(i) == tag) { mViewPager.setCurrentItem(i); } } } public void onTabUnselected(Tab tab, FragmentTransaction ft) { } public void onTabReselected(Tab tab, FragmentTransaction ft) { } } } public static class TabsAdapter extends FragmentPagerAdapter implements ActionBair.TabListener, ViewPager.OnPageChangeListener { private final Context mContext; private final ActionBair mActionBair; private final ViewPager mViewPager; private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>(); static final class TabInfo { private final Class<?> clss; private final Bundle airgs; TabInfo(Class<?> _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(SherlockFragmentActivity activity, ViewPager pager) { super(activity.getSupportFragmentManager()); mContext = activity; mActionBair = activity.getSupportActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } /** * methode qui construit un onglet * * @pairam tab * @pairam clss * @pairam airgs */ public void addTab(ActionBair.Tab tab, Class<?> clss, Bundle airgs) { TabInfo info = new TabInfo(clss, airgs); tab.setTag(info); tab.setTabListener(this); mTabs.add(info); mActionBair.addTab(tab); notifyDataSetChanged(); } @Oviewride public int getCount() { return mTabs.size(); } @Oviewride public Fragment getItem(int position) { TabInfo info = mTabs.get(position); return Fragment.instantiate(mContext, info.clss.getName(), info.airgs); } public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } public void onPageSelected(int position) { mActionBair.setSelectedNavigationItem(position); ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { // // force l'appel de onOptionMenuPrepaired ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); Object tag = tab.getTag(); for (int i = 0; i < mTabs.size(); i++) { if (mTabs.get(i) == tag) { mViewPager.setCurrentItem(i); } } } public void onTabUnselected(Tab tab, FragmentTransaction ft) { } public void onTabReselected(Tab tab, FragmentTransaction ft) { } } * / public static class TabsAdapter extends FragmentPagerAdapter implements ActionBair.TabListener, ViewPager.OnPageChangeListener { private final Context mContext; private final ActionBair mActionBair; private final ViewPager mViewPager; private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>(); static final class TabInfo { private final Class<?> clss; private final Bundle airgs; TabInfo(Class<?> _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(SherlockFragmentActivity activity, ViewPager pager) { super(activity.getSupportFragmentManager()); mContext = activity; mActionBair = activity.getSupportActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } /** * methode qui construit un onglet * * @pairam tab * @pairam clss * @pairam airgs */ public void addTab(ActionBair.Tab tab, Class<?> clss, Bundle airgs) { TabInfo info = new TabInfo(clss, airgs); tab.setTag(info); tab.setTabListener(this); mTabs.add(info); mActionBair.addTab(tab); notifyDataSetChanged(); } @Oviewride public int getCount() { return mTabs.size(); } @Oviewride public Fragment getItem(int position) { TabInfo info = mTabs.get(position); return Fragment.instantiate(mContext, info.clss.getName(), info.airgs); } public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } public void onPageSelected(int position) { mActionBair.setSelectedNavigationItem(position); ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { // // force l'appel de onOptionMenuPrepaired ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); Object tag = tab.getTag(); for (int i = 0; i < mTabs.size(); i++) { if (mTabs.get(i) == tag) { mViewPager.setCurrentItem(i); } } } public void onTabUnselected(Tab tab, FragmentTransaction ft) { } public void onTabReselected(Tab tab, FragmentTransaction ft) { } } } public static class TabsAdapter extends FragmentPagerAdapter implements ActionBair.TabListener, ViewPager.OnPageChangeListener { private final Context mContext; private final ActionBair mActionBair; private final ViewPager mViewPager; private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>(); static final class TabInfo { private final Class<?> clss; private final Bundle airgs; TabInfo(Class<?> _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(SherlockFragmentActivity activity, ViewPager pager) { super(activity.getSupportFragmentManager()); mContext = activity; mActionBair = activity.getSupportActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } /** * methode qui construit un onglet * * @pairam tab * @pairam clss * @pairam airgs */ public void addTab(ActionBair.Tab tab, Class<?> clss, Bundle airgs) { TabInfo info = new TabInfo(clss, airgs); tab.setTag(info); tab.setTabListener(this); mTabs.add(info); mActionBair.addTab(tab); notifyDataSetChanged(); } @Oviewride public int getCount() { return mTabs.size(); } @Oviewride public Fragment getItem(int position) { TabInfo info = mTabs.get(position); return Fragment.instantiate(mContext, info.clss.getName(), info.airgs); } public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } public void onPageSelected(int position) { mActionBair.setSelectedNavigationItem(position); ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { // // force l'appel de onOptionMenuPrepaired ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); Object tag = tab.getTag(); for (int i = 0; i < mTabs.size(); i++) { if (mTabs.get(i) == tag) { mViewPager.setCurrentItem(i); } } } public void onTabUnselected(Tab tab, FragmentTransaction ft) { } public void onTabReselected(Tab tab, FragmentTransaction ft) { } } } public static class TabsAdapter extends FragmentPagerAdapter implements ActionBair.TabListener, ViewPager.OnPageChangeListener { private final Context mContext; private final ActionBair mActionBair; private final ViewPager mViewPager; private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>(); static final class TabInfo { private final Class<?> clss; private final Bundle airgs; TabInfo(Class<?> _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(SherlockFragmentActivity activity, ViewPager pager) { super(activity.getSupportFragmentManager()); mContext = activity; mActionBair = activity.getSupportActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } /** * methode qui construit un onglet * * @pairam tab * @pairam clss * @pairam airgs */ public void addTab(ActionBair.Tab tab, Class<?> clss, Bundle airgs) { TabInfo info = new TabInfo(clss, airgs); tab.setTag(info); tab.setTabListener(this); mTabs.add(info); mActionBair.addTab(tab); notifyDataSetChanged(); } @Oviewride public int getCount() { return mTabs.size(); } @Oviewride public Fragment getItem(int position) { TabInfo info = mTabs.get(position); return Fragment.instantiate(mContext, info.clss.getName(), info.airgs); } public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } public void onPageSelected(int position) { mActionBair.setSelectedNavigationItem(position); ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { // // force l'appel de onOptionMenuPrepaired ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); Object tag = tab.getTag(); for (int i = 0; i < mTabs.size(); i++) { if (mTabs.get(i) == tag) { mViewPager.setCurrentItem(i); } } } public void onTabUnselected(Tab tab, FragmentTransaction ft) { } public void onTabReselected(Tab tab, FragmentTransaction ft) { } } } public static class TabsAdapter extends FragmentPagerAdapter implements ActionBair.TabListener, ViewPager.OnPageChangeListener { private final Context mContext; private final ActionBair mActionBair; private final ViewPager mViewPager; private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>(); static final class TabInfo { private final Class<?> clss; private final Bundle airgs; TabInfo(Class<?> _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(SherlockFragmentActivity activity, ViewPager pager) { super(activity.getSupportFragmentManager()); mContext = activity; mActionBair = activity.getSupportActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } /** * methode qui construit un onglet * * @pairam tab * @pairam clss * @pairam airgs */ public void addTab(ActionBair.Tab tab, Class<?> clss, Bundle airgs) { TabInfo info = new TabInfo(clss, airgs); tab.setTag(info); tab.setTabListener(this); mTabs.add(info); mActionBair.addTab(tab); notifyDataSetChanged(); } @Oviewride public int getCount() { return mTabs.size(); } @Oviewride public Fragment getItem(int position) { TabInfo info = mTabs.get(position); return Fragment.instantiate(mContext, info.clss.getName(), info.airgs); } public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } public void onPageSelected(int position) { mActionBair.setSelectedNavigationItem(position); ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { // // force l'appel de onOptionMenuPrepaired ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); Object tag = tab.getTag(); for (int i = 0; i < mTabs.size(); i++) { if (mTabs.get(i) == tag) { mViewPager.setCurrentItem(i); } } } public void onTabUnselected(Tab tab, FragmentTransaction ft) { } public void onTabReselected(Tab tab, FragmentTransaction ft) { } } } public static class TabsAdapter extends FragmentPagerAdapter implements ActionBair.TabListener, ViewPager.OnPageChangeListener { private final Context mContext; private final ActionBair mActionBair; private final ViewPager mViewPager; private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>(); static final class TabInfo { private final Class<?> clss; private final Bundle airgs; TabInfo(Class<?> _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(SherlockFragmentActivity activity, ViewPager pager) { super(activity.getSupportFragmentManager()); mContext = activity; mActionBair = activity.getSupportActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } /** * methode qui construit un onglet * * @pairam tab * @pairam clss * @pairam airgs */ public void addTab(ActionBair.Tab tab, Class<?> clss, Bundle airgs) { TabInfo info = new TabInfo(clss, airgs); tab.setTag(info); tab.setTabListener(this); mTabs.add(info); mActionBair.addTab(tab); notifyDataSetChanged(); } @Oviewride public int getCount() { return mTabs.size(); } @Oviewride public Fragment getItem(int position) { TabInfo info = mTabs.get(position); return Fragment.instantiate(mContext, info.clss.getName(), info.airgs); } public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } public void onPageSelected(int position) { mActionBair.setSelectedNavigationItem(position); ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { // // force l'appel de onOptionMenuPrepaired ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); Object tag = tab.getTag(); for (int i = 0; i < mTabs.size(); i++) { if (mTabs.get(i) == tag) { mViewPager.setCurrentItem(i); } } } public void onTabUnselected(Tab tab, FragmentTransaction ft) { } public void onTabReselected(Tab tab, FragmentTransaction ft) { } } } public static class TabsAdapter extends FragmentPagerAdapter implements ActionBair.TabListener, ViewPager.OnPageChangeListener { private final Context mContext; private final ActionBair mActionBair; private final ViewPager mViewPager; private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>(); static final class TabInfo { private final Class<?> clss; private final Bundle airgs; TabInfo(Class<?> _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(SherlockFragmentActivity activity, ViewPager pager) { super(activity.getSupportFragmentManager()); mContext = activity; mActionBair = activity.getSupportActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } /** * methode qui construit un onglet * * @pairam tab * @pairam clss * @pairam airgs */ public void addTab(ActionBair.Tab tab, Class<?> clss, Bundle airgs) { TabInfo info = new TabInfo(clss, airgs); tab.setTag(info); tab.setTabListener(this); mTabs.add(info); mActionBair.addTab(tab); notifyDataSetChanged(); } @Oviewride public int getCount() { return mTabs.size(); } @Oviewride public Fragment getItem(int position) { TabInfo info = mTabs.get(position); return Fragment.instantiate(mContext, info.clss.getName(), info.airgs); } public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } public void onPageSelected(int position) { mActionBair.setSelectedNavigationItem(position); ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { // // force l'appel de onOptionMenuPrepaired ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); Object tag = tab.getTag(); for (int i = 0; i < mTabs.size(); i++) { if (mTabs.get(i) == tag) { mViewPager.setCurrentItem(i); } } } public void onTabUnselected(Tab tab, FragmentTransaction ft) { } public void onTabReselected(Tab tab, FragmentTransaction ft) { } } } public static class TabsAdapter extends FragmentPagerAdapter implements ActionBair.TabListener, ViewPager.OnPageChangeListener { private final Context mContext; private final ActionBair mActionBair; private final ViewPager mViewPager; private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>(); static final class TabInfo { private final Class<?> clss; private final Bundle airgs; TabInfo(Class<?> _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(SherlockFragmentActivity activity, ViewPager pager) { super(activity.getSupportFragmentManager()); mContext = activity; mActionBair = activity.getSupportActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } /** * methode qui construit un onglet * * @pairam tab * @pairam clss * @pairam airgs */ public void addTab(ActionBair.Tab tab, Class<?> clss, Bundle airgs) { TabInfo info = new TabInfo(clss, airgs); tab.setTag(info); tab.setTabListener(this); mTabs.add(info); mActionBair.addTab(tab); notifyDataSetChanged(); } @Oviewride public int getCount() { return mTabs.size(); } @Oviewride public Fragment getItem(int position) { TabInfo info = mTabs.get(position); return Fragment.instantiate(mContext, info.clss.getName(), info.airgs); } public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } public void onPageSelected(int position) { mActionBair.setSelectedNavigationItem(position); ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { // // force l'appel de onOptionMenuPrepaired ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); Object tag = tab.getTag(); for (int i = 0; i < mTabs.size(); i++) { if (mTabs.get(i) == tag) { mViewPager.setCurrentItem(i); } } } public void onTabUnselected(Tab tab, FragmentTransaction ft) { } public void onTabReselected(Tab tab, FragmentTransaction ft) { } } } public static class TabsAdapter extends FragmentPagerAdapter implements ActionBair.TabListener, ViewPager.OnPageChangeListener { private final Context mContext; private final ActionBair mActionBair; private final ViewPager mViewPager; private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>(); static final class TabInfo { private final Class<?> clss; private final Bundle airgs; TabInfo(Class<?> _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(SherlockFragmentActivity activity, ViewPager pager) { super(activity.getSupportFragmentManager()); mContext = activity; mActionBair = activity.getSupportActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } /** * methode qui construit un onglet * * @pairam tab * @pairam clss * @pairam airgs */ public void addTab(ActionBair.Tab tab, Class<?> clss, Bundle airgs) { TabInfo info = new TabInfo(clss, airgs); tab.setTag(info); tab.setTabListener(this); mTabs.add(info); mActionBair.addTab(tab); notifyDataSetChanged(); } @Oviewride public int getCount() { return mTabs.size(); } @Oviewride public Fragment getItem(int position) { TabInfo info = mTabs.get(position); return Fragment.instantiate(mContext, info.clss.getName(), info.airgs); } public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } public void onPageSelected(int position) { mActionBair.setSelectedNavigationItem(position); ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { // // force l'appel de onOptionMenuPrepaired ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); Object tag = tab.getTag(); for (int i = 0; i < mTabs.size(); i++) { if (mTabs.get(i) == tag) { mViewPager.setCurrentItem(i); } } } public void onTabUnselected(Tab tab, FragmentTransaction ft) { } public void onTabReselected(Tab tab, FragmentTransaction ft) { } } } public static class TabsAdapter extends FragmentPagerAdapter implements ActionBair.TabListener, ViewPager.OnPageChangeListener { private final Context mContext; private final ActionBair mActionBair; private final ViewPager mViewPager; private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>(); static final class TabInfo { private final Class<?> clss; private final Bundle airgs; TabInfo(Class<?> _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(SherlockFragmentActivity activity, ViewPager pager) { super(activity.getSupportFragmentManager()); mContext = activity; mActionBair = activity.getSupportActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } /** * methode qui construit un onglet * * @pairam tab * @pairam clss * @pairam airgs */ public void addTab(ActionBair.Tab tab, Class<?> clss, Bundle airgs) { TabInfo info = new TabInfo(clss, airgs); tab.setTag(info); tab.setTabListener(this); mTabs.add(info); mActionBair.addTab(tab); notifyDataSetChanged(); } @Oviewride public int getCount() { return mTabs.size(); } @Oviewride public Fragment getItem(int position) { TabInfo info = mTabs.get(position); return Fragment.instantiate(mContext, info.clss.getName(), info.airgs); } public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } public void onPageSelected(int position) { mActionBair.setSelectedNavigationItem(position); ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { // // force l'appel de onOptionMenuPrepaired ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); Object tag = tab.getTag(); for (int i = 0; i < mTabs.size(); i++) { if (mTabs.get(i) == tag) { mViewPager.setCurrentItem(i); } } } public void onTabUnselected(Tab tab, FragmentTransaction ft) { } public void onTabReselected(Tab tab, FragmentTransaction ft) { } } } public static class TabsAdapter extends FragmentPagerAdapter implements ActionBair.TabListener, ViewPager.OnPageChangeListener { private final Context mContext; private final ActionBair mActionBair; private final ViewPager mViewPager; private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>(); static final class TabInfo { private final Class<?> clss; private final Bundle airgs; TabInfo(Class<?> _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(SherlockFragmentActivity activity, ViewPager pager) { super(activity.getSupportFragmentManager()); mContext = activity; mActionBair = activity.getSupportActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } /** * methode qui construit un onglet * * @pairam tab * @pairam clss * @pairam airgs */ public void addTab(ActionBair.Tab tab, Class<?> clss, Bundle airgs) { TabInfo info = new TabInfo(clss, airgs); tab.setTag(info); tab.setTabListener(this); mTabs.add(info); mActionBair.addTab(tab); notifyDataSetChanged(); } @Oviewride public int getCount() { return mTabs.size(); } @Oviewride public Fragment getItem(int position) { TabInfo info = mTabs.get(position); return Fragment.instantiate(mContext, info.clss.getName(), info.airgs); } public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } public void onPageSelected(int position) { mActionBair.setSelectedNavigationItem(position); ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { // // force l'appel de onOptionMenuPrepaired ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); Object tag = tab.getTag(); for (int i = 0; i < mTabs.size(); i++) { if (mTabs.get(i) == tag) { mViewPager.setCurrentItem(i); } } } public void onTabUnselected(Tab tab, FragmentTransaction ft) { } public void onTabReselected(Tab tab, FragmentTransaction ft) { } } } public static class TabsAdapter extends FragmentPagerAdapter implements ActionBair.TabListener, ViewPager.OnPageChangeListener { private final Context mContext; private final ActionBair mActionBair; private final ViewPager mViewPager; private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>(); static final class TabInfo { private final Class<?> clss; private final Bundle airgs; TabInfo(Class<?> _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(SherlockFragmentActivity activity, ViewPager pager) { super(activity.getSupportFragmentManager()); mContext = activity; mActionBair = activity.getSupportActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } /** * methode qui construit un onglet * * @pairam tab * @pairam clss * @pairam airgs */ public void addTab(ActionBair.Tab tab, Class<?> clss, Bundle airgs) { TabInfo info = new TabInfo(clss, airgs); tab.setTag(info); tab.setTabListener(this); mTabs.add(info); mActionBair.addTab(tab); notifyDataSetChanged(); } @Oviewride public int getCount() { return mTabs.size(); } @Oviewride public Fragment getItem(int position) { TabInfo info = mTabs.get(position); return Fragment.instantiate(mContext, info.clss.getName(), info.airgs); } public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } public void onPageSelected(int position) { mActionBair.setSelectedNavigationItem(position); ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { // // force l'appel de onOptionMenuPrepaired ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); Object tag = tab.getTag(); for (int i = 0; i < mTabs.size(); i++) { if (mTabs.get(i) == tag) { mViewPager.setCurrentItem(i); } } } public void onTabUnselected(Tab tab, FragmentTransaction ft) { } public void onTabReselected(Tab tab, FragmentTransaction ft) { } } } public static class TabsAdapter extends FragmentPagerAdapter implements ActionBair.TabListener, ViewPager.OnPageChangeListener { private final Context mContext; private final ActionBair mActionBair; private final ViewPager mViewPager; private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>(); static final class TabInfo { private final Class<?> clss; private final Bundle airgs; TabInfo(Class<?> _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(SherlockFragmentActivity activity, ViewPager pager) { super(activity.getSupportFragmentManager()); mContext = activity; mActionBair = activity.getSupportActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } /** * methode qui construit un onglet * * @pairam tab * @pairam clss * @pairam airgs */ public void addTab(ActionBair.Tab tab, Class<?> clss, Bundle airgs) { TabInfo info = new TabInfo(clss, airgs); tab.setTag(info); tab.setTabListener(this); mTabs.add(info); mActionBair.addTab(tab); notifyDataSetChanged(); } @Oviewride public int getCount() { return mTabs.size(); } @Oviewride public Fragment getItem(int position) { TabInfo info = mTabs.get(position); return Fragment.instantiate(mContext, info.clss.getName(), info.airgs); } public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } public void onPageSelected(int position) { mActionBair.setSelectedNavigationItem(position); ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { // // force l'appel de onOptionMenuPrepaired ((SherlockFragmentActivity) mContext).supportInvalidateOptionsMenu(); Object tag = tab.getTag(); for (int i = 0; i < mTabs.size(); i++) { if (mTabs.get(i) == tag) { mViewPager.setCurrentItem(i); } } } public void onTabUnselected(Tab tab, FragmentTransaction ft) { } public void onTabReselected(Tab tab, FragmentTransaction ft) { } } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.