Last active
October 5, 2015 04:41
-
-
Save sakdaped200/814995c0c9b190a82ce7 to your computer and use it in GitHub Desktop.
Demo-SwipeViewTap :: Source Code
This file contains 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 characters
package mostsofus.swipeviewtabs; | |
import android.os.Bundle; | |
import android.support.v4.view.ViewPager; | |
import android.support.v7.app.ActionBar; | |
import android.support.v7.app.ActionBarActivity; | |
import com.astuetz.PagerSlidingTabStrip; | |
public class MainActivity extends ActionBarActivity { | |
TabsPagerAdapter mAdapter; | |
ViewPager pager; | |
ActionBar actionBar; | |
String[] titles = {"TOP Rate", "Games", "Movies"}; | |
private PagerSlidingTabStrip tabs; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
//view matching.. | |
pager = (ViewPager) findViewById(R.id.pager); | |
tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs); | |
// create Class Adapter | |
mAdapter = new TabsPagerAdapter(getSupportFragmentManager()); | |
// setup Adapter | |
pager.setAdapter(mAdapter); | |
// กำหนด margin tabs | |
// final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources() | |
// .getDisplayMetrics()); | |
// pager.setPageMargin(pageMargin); | |
tabs.setViewPager(pager); | |
tabs.setIndicatorColor(0xCC666666); | |
// Drawable colorDrawable = new ColorDrawable(0xFF666666); | |
// Drawable bottomDrawable = getResources().getDrawable(R.drawable.actionbar_bottom); | |
// LayerDrawable ld = new LayerDrawable(new Drawable[] { colorDrawable, bottomDrawable }); | |
// actionBar = getSupportActionBar(); | |
// actionBar.setHomeButtonEnabled(false); | |
// actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); | |
//// | |
//// for (String tab_name : titles) { | |
////// actionBar.addTab(actionBar.newTab().setText(tab_name).setTabListener(this)); | |
//// tabs.addView(actionBar.newTab().setText(tab_name).setTabListener(this)); | |
//// | |
//// } | |
// add event when Swipe ViewPager | |
// pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { | |
// @Override | |
// public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { | |
// | |
// } | |
// | |
// @Override | |
// public void onPageSelected(int position) { | |
// // some thing.. | |
// actionBar.setSelectedNavigationItem(position); | |
// | |
// } | |
// | |
// @Override | |
// public void onPageScrollStateChanged(int state) { | |
// | |
// } | |
// }); | |
} | |
// @Override | |
// public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { | |
// pager.setCurrentItem(tab.getPosition()); | |
// } | |
// | |
// @Override | |
// public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { | |
// | |
// } | |
// | |
// @Override | |
// public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { | |
// | |
// } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment