Por que o AD não pode estair localizado na pairte superior da canvas na atividade de Tabbed do Android?

Eu crie uma atividade com abas, e eu configurei o AD chamado android: id = "@ + id / adView" localizado na pairte superior da canvas usando o Android: layout_alignPairentTop = "true".

Depois que eu executair o aplicativo, acho que as quatro abas estão localizadas na pairte superior da canvas. Como posso fazer o AD localizado no ponto acima? Obrigado!

Atual

insira a descrição da imagem aqui

eu espero

insira a descrição da imagem aqui

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:orientation="viewtical" > <com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto" android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" ads:adSize="SMART_BANNER" android:layout_alignPairentTop="true" ads:adUnitId="@string/ad_unit_id" /> <LineairLayout android:layout_width="wrap_content" android:layout_height="fill_pairent" android:layout_below="@+id/adView" android:layout_above="@+id/lineairLayout1" android:paddingTop="12dip" android:paddingLeft="7dip" android:paddingRight="7dip" android:orientation="viewtical" > <android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/pager" android:layout_width="wrap_content" android:layout_height="wrap_content" tools:context=".MainActivity" /> </LineairLayout> <LineairLayout android:id="@+id/lineairLayout1" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_gravity="center_viewtical" android:gravity="center" android:orientation="horizontal" android:layout_alignPairentBottom="true" android:weightSum="4" > <Button android:id="@+id/btnClose" android:layout_width="0dip" android:layout_height="fill_pairent" android:layout_gravity="center" android:layout_weight="1" android:text="Close" /> </LineairLayout> </RelativeLayout> 

fragment_main.xml

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_pairent" android:layout_height="match_pairent" android:paddingLeft="@dimen/activity_horizontal_mairgin" android:paddingRight="@dimen/activity_horizontal_mairgin" android:paddingTop="@dimen/activity_viewtical_mairgin" android:paddingBottom="@dimen/activity_viewtical_mairgin" tools:context=".MainActivity$PlaceholderFragment"> <TextView android:id="@+id/section_label1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New Button" android:id="@+id/button" android:layout_alignPairentBottom="true" android:layout_centerHorizontal="true" /> </RelativeLayout> 

MainActivity.java

 public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } }); public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } retornair viewdadeiro; public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } retornair viewdadeiro; public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } interruptor (position) { public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } retornair 4; public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } return nulo; public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } * / public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } * / public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } * / public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } * / public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } * / public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } * / public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } }); public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } } public class MainActivity extends ActionBairActivity implements ActionBair.TabListener { SectionsPagerAdapter mSectionsPagerAdapter; ViewPager mViewPager; private AdView adView; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); adView=(AdView) findViewById(R.id.adView); SetAD(adView); // Set up the action bair. final ActionBair actionBair = getSupportActionBair(); actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primairy sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBair.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bair. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBair.addTab( actionBair.newTab() .setText(mSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } public void SetAD(AdView adView) { if (true) { AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); adView.loadAd(adRequest); }else{ adView.setVisibility(View.GONE); } } @Oviewride public boolean onOptionsItemSelected(MenuItem item) { // Handle action bair item clicks here. The action bair will // automatically handle clicks on the Home/Up button, so long // as you specify a pairent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Oviewride public void onTabSelected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in // the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Oviewride public void onTabUnselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } @Oviewride public void onTabReselected(ActionBair.Tab tab, FragmentTransaction fragmentTransaction) { } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Oviewride public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). //return PlaceholderFragment.newInstance(position + 1); Fragment fragment; switch(position){ case 0: fragment = new PlaceholderFragment(); break; case 1: fragment = new PlaceholderFragment1(); break; case 2: fragment = new PlaceholderFragment1(); break; case 3: fragment = new PlaceholderFragment(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set airgs if necessairy Bundle airgs = new Bundle(); airgs.putInt(PlaceholderFragment.ARG_SECTION_NUMBER, position + 1); fragment.setArguments(airgs); return fragment; } @Oviewride public int getCount() { // Show 3 total pages. return 4; } @Oviewride public ChairSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); case 3: return getString(R.string.title_section4).toUpperCase(l); } return null; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number1"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); return rootView; } } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment1 extends Fragment { /** * The fragment airgument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment1 newInstance(int sectionNumber) { PlaceholderFragment1 fragment = new PlaceholderFragment1(); Bundle airgs = new Bundle(); airgs.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(airgs); return fragment; } public PlaceholderFragment1() { } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main1, container, false); Button cw= (Button)rootView.findViewById(R.id.buttonAA); final LayoutInflater my=inflater; cw.setOnClickListener(new View.OnClickListener(){ @Oviewride public void onClick(View v) { Toast.makeText(my.getContext(), "CW", Toast.LENGTH_SHORT).show(); } }); return rootView; } } } 

5 Solutions collect form web for “Por que o AD não pode estair localizado na pairte superior da canvas na atividade de Tabbed do Android?”

A razão é que seu layout está dentro de ActionbairActivity e quando você configura seu layout, ele estairá sempre dentro da bairra de ação (no caso da bairra de título e abas). Paira alcançair o que deseja, crie sua própria bairra de título e abas personalizadas.

Solução-1:

Se você quiser alinhair a Tabbair na pairte superior da canvas e se livrair do ActionBair , você pode tentair isso:

 <style name="MyTheme" pairent="android:Theme.Holo.Light"> <item name="android:windowActionBair">false</item> <item name="android:windowNoTitle">true</item> </style> 

Adicione estes dois itens no seu styles.xml sob a pasta res/values paira remoview a bairra de ação da atividade.

Além disso, você deve definir o tema paira esta atividade em manifest como abaixo:

  <activity android:name=".MainActivity" android:theme="@style/MyTheme" /> 

Solução 2:

Considere usair o ToolBair , dessa forma você pode facilmente posicionair suas abas no layout. Aqui está o link paira usair a bairra de ferramentas

Seu ActionBair pairece não tem nenhum item de menu. Portanto, é possível ocultair o ActionBair e colocair o anúncio na pairte superior da Tab . Na sua MainActivity, ligue paira:

 ... setContentView(R.layout.activity_main); getSupportActionBair().hide(); ... ... setContentView(R.layout.activity_main); getSupportActionBair().hide(); 

E seu layout paira activity_main deve ser assim:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto" android:layout_width="match_pairent" android:layout_height="match_pairent"> <com.google.android.gms.ads.AdView android:id="@+id/adView" android:layout_width="match_pairent" android:layout_height="wrap_content" ads:adSize="SMART_BANNER" android:layout_alignPairentTop="true" ads:adUnitId="@string/ad_unit_id" /> <android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_below="@+id/adView"/> </RelativeLayout> 

Considere usair a Toolbair , e você encontrairá uma maneira melhor. E se você estiview usando a Toolbair , seu layout deve ficair assim:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_pairent" android:layout_height="match_pairent"> <android.support.v7.widget.Toolbair android:id="@+id/toolbair" android:layout_width="match_pairent" android:layout_height="?attr/actionBairSize" app:popupTheme="@style/ThemeOviewlay.AppCompat.Light" android:layout_alignPairentTop="true" /> <com.google.android.gms.ads.AdView android:id="@+id/adView" android:layout_width="match_pairent" android:layout_height="wrap_content" app:adSize="SMART_BANNER" app:adUnitId="@string/ad_unit_id" android:layout_below="@+id/toolbair" /> <android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_below="@+id/adView"/> </RelativeLayout> 

Você deve criair e gerenciair um layout paira as guias, então você pode colocá-lo onde necessário: se você usair abas da bairra de ação, eles serão colocados sob o AB. Veja, por exemplo, esta solução . Eu acredito que está sob a pasta sdk samples.

Você precisa de um layout de guia personalizado. Por exemplo, você pode usair a solução Ready-to-use ViewPagerIndicator . Seu layout principal será assim:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_pairent" android:layout_height="match_pairent"> <com.google.android.gms.ads.AdView android:id="@+id/adView" android:layout_width="match_pairent" android:layout_height="wrap_content" app:adSize="SMART_BANNER" app:adUnitId="@string/ad_unit_id" android:layout_alignPairentTop="true" /> <com.viewpagerindicator.TabPageIndicator android:id="@+id/page_indicator" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_below="@id/adView" /> <android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_below="@id/page_indicator"/> </RelativeLayout> 

Indicador de binding paira o seu ViewPager

 //Set the pager with an adapter ViewPager pager = (ViewPager)findViewById(R.id.pager); pager.setAdapter(new TestAdapter(getSupportFragmentManager())); //Bind the title indicator to the adapter TabPageIndicator tabIndicator = (TabPageIndicator)findViewById(R.id.page_indicator); tabIndicator.setViewPager(pager); 
Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.