Last active
December 24, 2015 00:40
-
-
Save tonsV2/6718749 to your computer and use it in GitHub Desktop.
Revisions
-
snot revised this gist
Sep 26, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -48,7 +48,7 @@ public class TabsFragmentActivity extends FragmentActivity implements ActionBar. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tabs_activity); ta = new TabsAdapter(getSupportFragmentManager()); -
snot renamed this gist
Sep 26, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
tonsV2 revised this gist
Sep 26, 2013 . 1 changed file with 0 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -50,8 +50,6 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_tabs_pager); ta = new TabsAdapter(getSupportFragmentManager()); actionBar = getActionBar(); @@ -79,7 +77,6 @@ public void addTab(String title, Fragment f) ta.addTab(f); actionBar.addTab(actionBar.newTab().setText(title).setTabListener(this)); ta.notifyDataSetChanged(); } @Override @@ -96,7 +93,6 @@ public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransac public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { } private static class TabsAdapter extends FragmentPagerAdapter { List<Fragment> fragments = new ArrayList<Fragment>(); -
tonsV2 revised this gist
Sep 26, 2013 . No changes.There are no files selected for viewing
-
tonsV2 revised this gist
Sep 26, 2013 . 1 changed file with 62 additions and 47 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,64 +23,78 @@ * Created by snot on 6/20/13. */ //// Usage: // //public class MainActivity extends TabsFragmentActivity { // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // this.addTab(getString(R.string.tab_some_title), new SomeFragment()); // this.addTab(getString(R.string.tab_some_other_title), new SomeOtherFragment()); // this.addTab(getString(R.string.tab_yet_another_title), new YetAnotherFragment()); // } //} // public class TabsFragmentActivity extends FragmentActivity implements ActionBar.TabListener { private final String TAG = this.getClass().getName(); ViewPager mViewPager; TabsAdapter ta; ActionBar actionBar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_tabs_pager); ta = new TabsAdapter(getSupportFragmentManager()); actionBar = getActionBar(); final ActionBar factionBar = actionBar; // Set up the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Setup view pager mViewPager = (ViewPager)findViewById(R.id.pager); mViewPager.setAdapter(ta); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. factionBar.setSelectedNavigationItem(position); } }); } public void addTab(String title, Fragment f) { ta.addTab(f); actionBar.addTab(actionBar.newTab().setText(title).setTabListener(this)); ta.notifyDataSetChanged(); } @Override public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { } @Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Override public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { } private static class TabsAdapter extends FragmentPagerAdapter { @@ -106,3 +120,4 @@ public Fragment getItem(int position) { } } } -
tonsV2 revised this gist
Sep 26, 2013 . 1 changed file with 62 additions and 47 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,64 +23,78 @@ * Created by snot on 6/20/13. */ //// Usage: // //public class MainActivity extends TabsFragmentActivity { // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // this.addTab(getString(R.string.tab_some_title), new SomeFragment()); // this.addTab(getString(R.string.tab_some_other_title), new SomeOtherFragment()); // this.addTab(getString(R.string.tab_yet_another_title), new YetAnotherFragment()); // } //} // public class TabsFragmentActivity extends FragmentActivity implements ActionBar.TabListener { private final String TAG = this.getClass().getName(); ViewPager mViewPager; TabsAdapter ta; ActionBar actionBar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_tabs_pager); ta = new TabsAdapter(getSupportFragmentManager()); actionBar = getActionBar(); final ActionBar factionBar = actionBar; // Set up the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Setup view pager mViewPager = (ViewPager)findViewById(R.id.pager); mViewPager.setAdapter(ta); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. factionBar.setSelectedNavigationItem(position); } }); } public void addTab(String title, Fragment f) { ta.addTab(f); actionBar.addTab(actionBar.newTab().setText(title).setTabListener(this)); ta.notifyDataSetChanged(); } @Override public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { } @Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Override public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { } private static class TabsAdapter extends FragmentPagerAdapter { @@ -106,3 +120,4 @@ public Fragment getItem(int position) { } } } -
snot revised this gist
Sep 26, 2013 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ <android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="match_parent" /> -
tonsV2 created this gist
Sep 26, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,108 @@ package com.snot.bloatware; import android.content.Context; import android.os.Bundle; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.Fragment; import android.support.v4.view.ViewPager; import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.TabHost; import android.widget.TabWidget; import android.app.ActionBar; import android.app.FragmentTransaction; import java.util.List; import java.util.ArrayList; /** * Created by snot on 6/20/13. */ public class TabsFragmentActivity extends FragmentActivity implements ActionBar.TabListener { private final String TAG = this.getClass().getName(); ViewPager mViewPager; TabsAdapter ta; ActionBar actionBar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_tabs_pager); ta = new TabsAdapter(getSupportFragmentManager()); actionBar = getActionBar(); final ActionBar factionBar = actionBar; // Set up the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Setup view pager mViewPager = (ViewPager)findViewById(R.id.pager); mViewPager.setAdapter(ta); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. factionBar.setSelectedNavigationItem(position); } }); } public void addTab(String title, Fragment f) { ta.addTab(f); actionBar.addTab(actionBar.newTab().setText(title).setTabListener(this)); ta.notifyDataSetChanged(); } @Override public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { } @Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); } @Override public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { } private static class TabsAdapter extends FragmentPagerAdapter { List<Fragment> fragments = new ArrayList<Fragment>(); public TabsAdapter(FragmentManager fragmentManager) { super(fragmentManager); } public void addTab(Fragment fragment) { fragments.add(fragment); } @Override public int getCount() { return fragments.size(); } @Override public Fragment getItem(int position) { return fragments.get(position); } } }