use of android.support.design.widget.TabLayout in project Android-skin-support by ximsfei.
the class MaterialDesignActivity method configFragments.
private void configFragments() {
List<Fragment> list = new ArrayList<>();
list.add(new MDFirstFragment());
// list.add(new MiddleFragment());
// list.add(new LastFragment());
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
List<String> listTitle = new ArrayList<>();
listTitle.add("系统组件");
// listTitle.add("自定义View");
// listTitle.add("第三方库控件");
mTabFragmentPagerAdapter = new TabFragmentPagerAdapter(getSupportFragmentManager(), list, listTitle);
viewPager.setAdapter(mTabFragmentPagerAdapter);
tabLayout.setupWithViewPager(viewPager);
}
use of android.support.design.widget.TabLayout in project WordPress-Android by wordpress-mobile.
the class ReaderSubsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.reader_activity_subs);
restoreState(savedInstanceState);
mViewPager = (WPViewPager) findViewById(R.id.viewpager);
mViewPager.setOffscreenPageLimit(NUM_TABS - 1);
mViewPager.setAdapter(getPageAdapter());
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
int normalColor = ContextCompat.getColor(this, R.color.blue_light);
int selectedColor = ContextCompat.getColor(this, R.color.white);
tabLayout.setTabTextColors(normalColor, selectedColor);
tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
tabLayout.setupWithViewPager(mViewPager);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
if (toolbar != null) {
setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
}
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
// Shadow removed on Activities with a tab toolbar
actionBar.setElevation(0.0f);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
}
mEditAdd = (EditText) findViewById(R.id.edit_add);
mEditAdd.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
addCurrentEntry();
}
return false;
}
});
mBtnAdd = (ImageButton) findViewById(R.id.btn_add);
mBtnAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
addCurrentEntry();
}
});
if (savedInstanceState == null) {
// return to the page the user was on the last time they viewed this activity
restorePreviousPage();
}
// note this listener must be assigned after we've already called restorePreviousPage()
mViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
// remember which page the user last viewed
String pageTitle = (String) getPageAdapter().getPageTitle(position);
AppPrefs.setReaderSubsPageTitle(pageTitle);
}
});
}
use of android.support.design.widget.TabLayout in project AdMoney by ErnestoGonAr.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
bd = new BDHandlerAM(this);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.container);
mViewPager.setAdapter(mSectionsPagerAdapter);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(mViewPager);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
}
use of android.support.design.widget.TabLayout in project leo-app by LCA311.
the class WrapperQRActivity method onCreate.
/* private ZXingScannerView scV;
public static Button scan;
private final int MY_PERMISSIONS_REQUEST_USE_CAMERA = 0;
private boolean runningScan; */
@Override
protected void onCreate(Bundle savedInstanceState) {
/* super.onCreate(savedInstanceState);
setContentView(R.layout.activity_wrapper_qr); */
//---- START TOOLBAR ---- //
Toolbar myToolbar = (Toolbar) findViewById(R.id.toolbar);
// runningScan = false;
setSupportActionBar(myToolbar);
//If it's stupid, but it works it's not stupid
getSupportActionBar().setTitle(Html.fromHtml("<font color=\"#ffffff\">" + getString(R.string.toolbar_title) + "</font>"));
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
//---- ENDE TOOLBAR ---- //
//---- START TABS ---- //
mViewPager = (ViewPager) findViewById(R.id.pager);
FragmentPagerAdapter adapt = new FragmentPagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int position) {
if (position == 0)
//QRActivity ist ein Fragment trotz des Namens
return new QRActivity();
else
//ScanActivity ist ein Fragment trotz des Namens
return new ScanActivity();
}
@Override
public int getCount() {
return 2;
}
@Override
public CharSequence getPageTitle(int position) {
if (position == 0)
return getString(R.string.toolbar_qr);
else
return getString(R.string.toolbar_scan);
}
};
mViewPager.setAdapter(adapt);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tablayout);
tabLayout.setupWithViewPager(mViewPager);
//---- ENDE TABS ---- //
/* sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
sqlh = new SQLiteHandler(getApplicationContext());
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
scan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
scan();
}
});
}
}, 100); */
}
use of android.support.design.widget.TabLayout in project SR-Tracker-for-Overwatch by Rexios80.
the class InformationActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (dpWidth() >= 1000) {
setContentView(R.layout.activity_information_tablet);
} else if (dpWidth() > 750) {
setContentView(R.layout.activity_information_hybrid);
} else {
setContentView(R.layout.activity_information_phone);
}
if (savedInstanceState != null) {
Log.i("InformationActivity", "Saved instance restored - " + savedInstanceState.getString("season"));
DatabaseContract.Database.CURRENT_SEASON_TABLE_NAME = savedInstanceState.getString("season");
}
Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
String seasonNumber = DatabaseContract.Database.CURRENT_SEASON_TABLE_NAME.substring(6);
getSupportActionBar().setTitle(" Season " + seasonNumber);
switch(seasonNumber) {
case "1":
getSupportActionBar().setIcon(R.drawable.season1);
break;
case "2":
getSupportActionBar().setIcon(R.drawable.season2);
break;
case "3":
getSupportActionBar().setIcon(R.drawable.season3);
break;
case "4":
getSupportActionBar().setIcon(R.drawable.season4);
break;
case "5":
getSupportActionBar().setIcon(R.drawable.season5);
break;
}
if (dpWidth() >= 1000) {
statsFragment = (StatsFragment) getSupportFragmentManager().findFragmentById(R.id.stats_fragment);
mapsFragment = (MapsFragment) getSupportFragmentManager().findFragmentById(R.id.maps_fragment);
totalsFragment = (TotalsFragment) getSupportFragmentManager().findFragmentById(R.id.totals_fragment);
analysisFragment = (AnalysisFragment) getSupportFragmentManager().findFragmentById(R.id.analysis_fragment);
} else if (dpWidth() > 750) {
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout_hybrid);
mViewPager = (ViewPager) findViewById(R.id.pager_hybrid);
mPagerAdapterHybrid = new TabPagerAdapterHybrid((getSupportFragmentManager()), tabLayout.getTabCount());
mViewPager.setAdapter(mPagerAdapterHybrid);
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
mViewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
} else {
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout_phone);
mViewPager = (ViewPager) findViewById(R.id.pager_phone);
mPagerAdapterPhone = new TabPagerAdapterPhone((getSupportFragmentManager()), tabLayout.getTabCount());
mViewPager.setAdapter(mPagerAdapterPhone);
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
mViewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
}
}
Aggregations