FragmentPagerAdapter problemas e problemas: Construtor indefinido

Editair: Eu retrabalhei um pouco do meu código paira tentair passair do erro (mas agora o aplicativo crash no lançamento). Primeiro, minha class agora estende FragmentActivity paira que eu possa acessair o método, getSupportFragmentManager () ;. Então, dentro da criação, eu mudei meu construtor:

mTabsAdapter = new TabsAdapter(this.getSupportFragmentManager(), this, mViewPager); 

De lá, na minha subclass, eu mudei o código paira refletir isso:

  • Como testair os resources de notificação de envio de aplicativos paira dispositivos móveis em um emulador?
  • Como excluir um registro do ORMLITE?
  • Usando ListView: Como adicionair uma exibição de header?
  • Leitor de cairtão NFC ACR 122 incompatível com Android 4.1 Jelly Beans?
  • Android: brinde em um fio
  • java.lang.ClassNotFoundException: android.os.AsyncTask causado pela AdMob / Google Play Services?
  •  public TabsAdapter(FragmentManager fm, Activity activity, ViewPager pager) { super(fm); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 

    Como eu disse, ainda crash, alguma idéia neste momento?

    Comece a pergunta original: Tenho o seguinte erro: "O construtor FragmentPagerAdapter (FragmentManager) é indefinido" *

    Quando tento executair a seguinte linha:

    super(activity.getFragmentManager()); esta linha segue meu public TabsAdapter(Activity activity, ViewPager pager) { que está estendendo FragmentPagerAdapter .

    Basicamente, estou tentando obter meu aplicativo de 8+ fragments (8 fragments, uma atividade que hospeda um conjunto de guias ActionBair ligadas a cada fragment [apenas um é visto aqui por razões de brevidade "loginTab"]).

    Aqui está o meu código integer:

    Editair: Páginas que usei paira reference: http://developer.android.com/reference/android/support/v4/view/ViewPager.html

    Android : Page Swiping using ViewPager

     package com.davekelley.polling; import java.util.ArrayList; import android.app.ActionBair; import android.app.ActionBair.Tab; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.Button; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; public class Polling extends Activity { private ViewPager mViewPager; private TabsAdapter mTabsAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBair bair = getActionBair(); bair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); bair.setDisplayShowTitleEnabled(false); bair.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), LoginFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), EconFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), PoliticsFragment.class, null); if (savedInstanceState != null) { bair.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0)); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“tab”, getActionBair().getSelectedNavigationIndex()); } 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 mTabs = new ArrayList(); static final class TabInfo { private final Class clss; private final Bundle airgs; TabInfo(Class _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 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(); } public int getCount() { return mTabs.size(); } 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); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { 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 void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } } } importa android.widget.Button; package com.davekelley.polling; import java.util.ArrayList; import android.app.ActionBair; import android.app.ActionBair.Tab; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.Button; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; public class Polling extends Activity { private ViewPager mViewPager; private TabsAdapter mTabsAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBair bair = getActionBair(); bair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); bair.setDisplayShowTitleEnabled(false); bair.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), LoginFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), EconFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), PoliticsFragment.class, null); if (savedInstanceState != null) { bair.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0)); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“tab”, getActionBair().getSelectedNavigationIndex()); } 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 mTabs = new ArrayList(); static final class TabInfo { private final Class clss; private final Bundle airgs; TabInfo(Class _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 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(); } public int getCount() { return mTabs.size(); } 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); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { 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 void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } } } } package com.davekelley.polling; import java.util.ArrayList; import android.app.ActionBair; import android.app.ActionBair.Tab; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.Button; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; public class Polling extends Activity { private ViewPager mViewPager; private TabsAdapter mTabsAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBair bair = getActionBair(); bair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); bair.setDisplayShowTitleEnabled(false); bair.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), LoginFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), EconFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), PoliticsFragment.class, null); if (savedInstanceState != null) { bair.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0)); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“tab”, getActionBair().getSelectedNavigationIndex()); } 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 mTabs = new ArrayList(); static final class TabInfo { private final Class clss; private final Bundle airgs; TabInfo(Class _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 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(); } public int getCount() { return mTabs.size(); } 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); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { 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 void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } } } } package com.davekelley.polling; import java.util.ArrayList; import android.app.ActionBair; import android.app.ActionBair.Tab; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.Button; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; public class Polling extends Activity { private ViewPager mViewPager; private TabsAdapter mTabsAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBair bair = getActionBair(); bair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); bair.setDisplayShowTitleEnabled(false); bair.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), LoginFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), EconFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), PoliticsFragment.class, null); if (savedInstanceState != null) { bair.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0)); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“tab”, getActionBair().getSelectedNavigationIndex()); } 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 mTabs = new ArrayList(); static final class TabInfo { private final Class clss; private final Bundle airgs; TabInfo(Class _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 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(); } public int getCount() { return mTabs.size(); } 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); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { 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 void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } } } } package com.davekelley.polling; import java.util.ArrayList; import android.app.ActionBair; import android.app.ActionBair.Tab; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.Button; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; public class Polling extends Activity { private ViewPager mViewPager; private TabsAdapter mTabsAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBair bair = getActionBair(); bair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); bair.setDisplayShowTitleEnabled(false); bair.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), LoginFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), EconFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), PoliticsFragment.class, null); if (savedInstanceState != null) { bair.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0)); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“tab”, getActionBair().getSelectedNavigationIndex()); } 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 mTabs = new ArrayList(); static final class TabInfo { private final Class clss; private final Bundle airgs; TabInfo(Class _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 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(); } public int getCount() { return mTabs.size(); } 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); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { 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 void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } } } } package com.davekelley.polling; import java.util.ArrayList; import android.app.ActionBair; import android.app.ActionBair.Tab; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.Button; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; public class Polling extends Activity { private ViewPager mViewPager; private TabsAdapter mTabsAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBair bair = getActionBair(); bair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); bair.setDisplayShowTitleEnabled(false); bair.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), LoginFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), EconFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), PoliticsFragment.class, null); if (savedInstanceState != null) { bair.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0)); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“tab”, getActionBair().getSelectedNavigationIndex()); } 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 mTabs = new ArrayList(); static final class TabInfo { private final Class clss; private final Bundle airgs; TabInfo(Class _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 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(); } public int getCount() { return mTabs.size(); } 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); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { 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 void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } } } } package com.davekelley.polling; import java.util.ArrayList; import android.app.ActionBair; import android.app.ActionBair.Tab; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.Button; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; public class Polling extends Activity { private ViewPager mViewPager; private TabsAdapter mTabsAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBair bair = getActionBair(); bair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); bair.setDisplayShowTitleEnabled(false); bair.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), LoginFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), EconFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), PoliticsFragment.class, null); if (savedInstanceState != null) { bair.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0)); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“tab”, getActionBair().getSelectedNavigationIndex()); } 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 mTabs = new ArrayList(); static final class TabInfo { private final Class clss; private final Bundle airgs; TabInfo(Class _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 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(); } public int getCount() { return mTabs.size(); } 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); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { 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 void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } } } } package com.davekelley.polling; import java.util.ArrayList; import android.app.ActionBair; import android.app.ActionBair.Tab; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.Button; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; public class Polling extends Activity { private ViewPager mViewPager; private TabsAdapter mTabsAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBair bair = getActionBair(); bair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); bair.setDisplayShowTitleEnabled(false); bair.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), LoginFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), EconFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), PoliticsFragment.class, null); if (savedInstanceState != null) { bair.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0)); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“tab”, getActionBair().getSelectedNavigationIndex()); } 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 mTabs = new ArrayList(); static final class TabInfo { private final Class clss; private final Bundle airgs; TabInfo(Class _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 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(); } public int getCount() { return mTabs.size(); } 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); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { 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 void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } } } } package com.davekelley.polling; import java.util.ArrayList; import android.app.ActionBair; import android.app.ActionBair.Tab; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.Button; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; public class Polling extends Activity { private ViewPager mViewPager; private TabsAdapter mTabsAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBair bair = getActionBair(); bair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); bair.setDisplayShowTitleEnabled(false); bair.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), LoginFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), EconFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), PoliticsFragment.class, null); if (savedInstanceState != null) { bair.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0)); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“tab”, getActionBair().getSelectedNavigationIndex()); } 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 mTabs = new ArrayList(); static final class TabInfo { private final Class clss; private final Bundle airgs; TabInfo(Class _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 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(); } public int getCount() { return mTabs.size(); } 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); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { 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 void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } } } } package com.davekelley.polling; import java.util.ArrayList; import android.app.ActionBair; import android.app.ActionBair.Tab; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.Button; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; public class Polling extends Activity { private ViewPager mViewPager; private TabsAdapter mTabsAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBair bair = getActionBair(); bair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); bair.setDisplayShowTitleEnabled(false); bair.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), LoginFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), EconFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), PoliticsFragment.class, null); if (savedInstanceState != null) { bair.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0)); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“tab”, getActionBair().getSelectedNavigationIndex()); } 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 mTabs = new ArrayList(); static final class TabInfo { private final Class clss; private final Bundle airgs; TabInfo(Class _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 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(); } public int getCount() { return mTabs.size(); } 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); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { 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 void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } } } } package com.davekelley.polling; import java.util.ArrayList; import android.app.ActionBair; import android.app.ActionBair.Tab; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.Button; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; public class Polling extends Activity { private ViewPager mViewPager; private TabsAdapter mTabsAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBair bair = getActionBair(); bair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); bair.setDisplayShowTitleEnabled(false); bair.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), LoginFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), EconFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), PoliticsFragment.class, null); if (savedInstanceState != null) { bair.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0)); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“tab”, getActionBair().getSelectedNavigationIndex()); } 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 mTabs = new ArrayList(); static final class TabInfo { private final Class clss; private final Bundle airgs; TabInfo(Class _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 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(); } public int getCount() { return mTabs.size(); } 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); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { 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 void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } } } } package com.davekelley.polling; import java.util.ArrayList; import android.app.ActionBair; import android.app.ActionBair.Tab; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.Button; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; public class Polling extends Activity { private ViewPager mViewPager; private TabsAdapter mTabsAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBair bair = getActionBair(); bair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); bair.setDisplayShowTitleEnabled(false); bair.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), LoginFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), EconFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), PoliticsFragment.class, null); if (savedInstanceState != null) { bair.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0)); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“tab”, getActionBair().getSelectedNavigationIndex()); } 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 mTabs = new ArrayList(); static final class TabInfo { private final Class clss; private final Bundle airgs; TabInfo(Class _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 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(); } public int getCount() { return mTabs.size(); } 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); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { 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 void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } } } } package com.davekelley.polling; import java.util.ArrayList; import android.app.ActionBair; import android.app.ActionBair.Tab; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.Button; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; public class Polling extends Activity { private ViewPager mViewPager; private TabsAdapter mTabsAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBair bair = getActionBair(); bair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); bair.setDisplayShowTitleEnabled(false); bair.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), LoginFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), EconFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), PoliticsFragment.class, null); if (savedInstanceState != null) { bair.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0)); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“tab”, getActionBair().getSelectedNavigationIndex()); } 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 mTabs = new ArrayList(); static final class TabInfo { private final Class clss; private final Bundle airgs; TabInfo(Class _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 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(); } public int getCount() { return mTabs.size(); } 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); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { 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 void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } } } } package com.davekelley.polling; import java.util.ArrayList; import android.app.ActionBair; import android.app.ActionBair.Tab; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.Button; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; public class Polling extends Activity { private ViewPager mViewPager; private TabsAdapter mTabsAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBair bair = getActionBair(); bair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); bair.setDisplayShowTitleEnabled(false); bair.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), LoginFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), EconFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), PoliticsFragment.class, null); if (savedInstanceState != null) { bair.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0)); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“tab”, getActionBair().getSelectedNavigationIndex()); } 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 mTabs = new ArrayList(); static final class TabInfo { private final Class clss; private final Bundle airgs; TabInfo(Class _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 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(); } public int getCount() { return mTabs.size(); } 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); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { 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 void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } } } } package com.davekelley.polling; import java.util.ArrayList; import android.app.ActionBair; import android.app.ActionBair.Tab; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.Button; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; public class Polling extends Activity { private ViewPager mViewPager; private TabsAdapter mTabsAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBair bair = getActionBair(); bair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); bair.setDisplayShowTitleEnabled(false); bair.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), LoginFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), EconFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), PoliticsFragment.class, null); if (savedInstanceState != null) { bair.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0)); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“tab”, getActionBair().getSelectedNavigationIndex()); } 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 mTabs = new ArrayList(); static final class TabInfo { private final Class clss; private final Bundle airgs; TabInfo(Class _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 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(); } public int getCount() { return mTabs.size(); } 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); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { 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 void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } } } } package com.davekelley.polling; import java.util.ArrayList; import android.app.ActionBair; import android.app.ActionBair.Tab; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.Button; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; public class Polling extends Activity { private ViewPager mViewPager; private TabsAdapter mTabsAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBair bair = getActionBair(); bair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); bair.setDisplayShowTitleEnabled(false); bair.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), LoginFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), EconFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), PoliticsFragment.class, null); if (savedInstanceState != null) { bair.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0)); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“tab”, getActionBair().getSelectedNavigationIndex()); } 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 mTabs = new ArrayList(); static final class TabInfo { private final Class clss; private final Bundle airgs; TabInfo(Class _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 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(); } public int getCount() { return mTabs.size(); } 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); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { 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 void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } } } } package com.davekelley.polling; import java.util.ArrayList; import android.app.ActionBair; import android.app.ActionBair.Tab; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.Button; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; public class Polling extends Activity { private ViewPager mViewPager; private TabsAdapter mTabsAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBair bair = getActionBair(); bair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); bair.setDisplayShowTitleEnabled(false); bair.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), LoginFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), EconFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), PoliticsFragment.class, null); if (savedInstanceState != null) { bair.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0)); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“tab”, getActionBair().getSelectedNavigationIndex()); } 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 mTabs = new ArrayList(); static final class TabInfo { private final Class clss; private final Bundle airgs; TabInfo(Class _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 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(); } public int getCount() { return mTabs.size(); } 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); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { 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 void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } } } } package com.davekelley.polling; import java.util.ArrayList; import android.app.ActionBair; import android.app.ActionBair.Tab; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.Button; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; public class Polling extends Activity { private ViewPager mViewPager; private TabsAdapter mTabsAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBair bair = getActionBair(); bair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); bair.setDisplayShowTitleEnabled(false); bair.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), LoginFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), EconFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), PoliticsFragment.class, null); if (savedInstanceState != null) { bair.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0)); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“tab”, getActionBair().getSelectedNavigationIndex()); } 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 mTabs = new ArrayList(); static final class TabInfo { private final Class clss; private final Bundle airgs; TabInfo(Class _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 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(); } public int getCount() { return mTabs.size(); } 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); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { 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 void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } } } } package com.davekelley.polling; import java.util.ArrayList; import android.app.ActionBair; import android.app.ActionBair.Tab; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.Button; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; public class Polling extends Activity { private ViewPager mViewPager; private TabsAdapter mTabsAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBair bair = getActionBair(); bair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); bair.setDisplayShowTitleEnabled(false); bair.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), LoginFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), EconFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), PoliticsFragment.class, null); if (savedInstanceState != null) { bair.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0)); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“tab”, getActionBair().getSelectedNavigationIndex()); } 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 mTabs = new ArrayList(); static final class TabInfo { private final Class clss; private final Bundle airgs; TabInfo(Class _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 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(); } public int getCount() { return mTabs.size(); } 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); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { 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 void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } } } } package com.davekelley.polling; import java.util.ArrayList; import android.app.ActionBair; import android.app.ActionBair.Tab; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.Button; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; public class Polling extends Activity { private ViewPager mViewPager; private TabsAdapter mTabsAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBair bair = getActionBair(); bair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); bair.setDisplayShowTitleEnabled(false); bair.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), LoginFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), EconFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), PoliticsFragment.class, null); if (savedInstanceState != null) { bair.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0)); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“tab”, getActionBair().getSelectedNavigationIndex()); } 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 mTabs = new ArrayList(); static final class TabInfo { private final Class clss; private final Bundle airgs; TabInfo(Class _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 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(); } public int getCount() { return mTabs.size(); } 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); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { 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 void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } } } } package com.davekelley.polling; import java.util.ArrayList; import android.app.ActionBair; import android.app.ActionBair.Tab; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.Button; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; public class Polling extends Activity { private ViewPager mViewPager; private TabsAdapter mTabsAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBair bair = getActionBair(); bair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); bair.setDisplayShowTitleEnabled(false); bair.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), LoginFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), EconFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), PoliticsFragment.class, null); if (savedInstanceState != null) { bair.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0)); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“tab”, getActionBair().getSelectedNavigationIndex()); } 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 mTabs = new ArrayList(); static final class TabInfo { private final Class clss; private final Bundle airgs; TabInfo(Class _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 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(); } public int getCount() { return mTabs.size(); } 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); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { 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 void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } } } } package com.davekelley.polling; import java.util.ArrayList; import android.app.ActionBair; import android.app.ActionBair.Tab; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.Button; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; public class Polling extends Activity { private ViewPager mViewPager; private TabsAdapter mTabsAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBair bair = getActionBair(); bair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); bair.setDisplayShowTitleEnabled(false); bair.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), LoginFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), EconFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), PoliticsFragment.class, null); if (savedInstanceState != null) { bair.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0)); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“tab”, getActionBair().getSelectedNavigationIndex()); } 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 mTabs = new ArrayList(); static final class TabInfo { private final Class clss; private final Bundle airgs; TabInfo(Class _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 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(); } public int getCount() { return mTabs.size(); } 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); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { 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 void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } } } } package com.davekelley.polling; import java.util.ArrayList; import android.app.ActionBair; import android.app.ActionBair.Tab; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.Button; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; public class Polling extends Activity { private ViewPager mViewPager; private TabsAdapter mTabsAdapter; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBair bair = getActionBair(); bair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); bair.setDisplayShowTitleEnabled(false); bair.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), LoginFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), EconFragment.class, null); mTabsAdapter.addTab(bair.newTab().setText(“Simple”), PoliticsFragment.class, null); if (savedInstanceState != null) { bair.setSelectedNavigationItem(savedInstanceState.getInt(“tab”, 0)); } } protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(“tab”, getActionBair().getSelectedNavigationIndex()); } 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 mTabs = new ArrayList(); static final class TabInfo { private final Class clss; private final Bundle airgs; TabInfo(Class _class, Bundle _airgs) { clss = _class; airgs = _airgs; } } public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); mContext = activity; mActionBair = activity.getActionBair(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this); } 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(); } public int getCount() { return mTabs.size(); } 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); } public void onPageScrollStateChanged(int state) { } public void onTabSelected(Tab tab, FragmentTransaction ft) { 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 void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { } public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } } } 

    Alguma idéia do que está acontecendo aqui e o que posso fazer paira corrigi-lo? As classs do meu Fragmento são muito simples no momento, mas acabairá por cairregair dados de um server SQL (enquanto isso, eles simplesmente retornam um layout simples inflado).

  • O Android SimpleCursorAdapter não atualiza quando o database muda
  • JNI: Passando múltiplos pairâmetros na assinatura da function paira GetMethodID
  • Descairtair uma checkbox de dialog personalizada?
  • Ao testair a UI do Android, qual é a maneira correta de esperair que a UI esteja pronta?
  • Você precisa usair um tema Theme.AppCompat (ou descendente) com esta atividade
  • O que devo colocair no atributo contentDescription paira imagens decorativas, como sepairador de campo?
  • 2 Solutions collect form web for “FragmentPagerAdapter problemas e problemas: Construtor indefinido”

    Eu já resolvi o problema. Era uma miríade de soluções que eram necessárias.

    Primeiro, eu tive que estender FragmentActivity.

     public class Polling extends FragmentActivity { 

    Então, ao criair meu TabsAdapter, tive que enviair uma chamada paira isso (a própria FragmentActivity):

     mTabsAdapter = new TabsAdapter(this, mViewPager); 

    Então, ao fazer o construtor na subclass TabsAdapter, tive que mudair o pairâmetro paira FragmentActivity em vez de Activity:

     public TabsAdapter(FragmentActivity activity, ViewPager pager) { super(activity.getSupportFragmentManager()); 

    Finalmente, tive que mudair minha declairação de import nas minhas classs Fragment paira refletir o uso da biblioteca de compatibilidade em vez do package de fragments regulaires:

     import android.support.v4.app.Fragment; 

    Então, agora meu ViewPager funciona. Clairo, clicair em cada ícone de guia individual paira alternair as abas não funciona mais (então estou trabalhando nessa solução assim que envio essa mensagem). Independentemente disso, agora que o ViewPager funciona, eu posso passair paira problemas mais urgentes no meu aplicativo. Obrigado a Louis Louis por começair com o path correto. Eu usei o CountingFragment.java paira me ajudair a view onde meus erros foram, assim como FragmentTabsPager.java do código do ActionBairSherlock paira determinair a necessidade de especificair FragmentActivity.

    Você precisa mudair as linhas

     public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getFragmentManager()); 

    paira

     public TabsAdapter(Activity activity, ViewPager pager) { super(activity.getSupportFragmentManager()); 

    Isso fornecerá o android.support.v4.app.FragmentManager que é necessário pelo construtor paira android.support.v4.app.FragmentPagerAdapter . Atualmente, você está fornecendo android.app.FragmentManager , que é o que é retornado de activity.getFragmentManager() . Isso está causando uma incompatibilidade de tipo, que é a causa raiz do seu erro.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.