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 materialistic by hidroh.
the class UserActivity method onCreate.
@SuppressWarnings("ConstantConditions")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mUsername = getIntent().getStringExtra(EXTRA_USERNAME);
if (TextUtils.isEmpty(mUsername)) {
mUsername = AppUtils.getDataUriId(getIntent(), PARAM_ID);
}
if (TextUtils.isEmpty(mUsername)) {
finish();
return;
}
setTaskTitle(mUsername);
AppUtils.setStatusBarDim(getWindow(), true);
setContentView(R.layout.activity_user);
findViewById(R.id.touch_outside).setOnClickListener(v -> finish());
mBottomSheetBehavior = BottomSheetBehavior.from(findViewById(R.id.bottom_sheet));
mBottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
switch(newState) {
case BottomSheetBehavior.STATE_HIDDEN:
finish();
break;
case BottomSheetBehavior.STATE_EXPANDED:
AppUtils.setStatusBarDim(getWindow(), false);
mRecyclerView.setLayoutFrozen(false);
break;
default:
AppUtils.setStatusBarDim(getWindow(), true);
break;
}
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
// no op
}
});
mTitle = (TextView) findViewById(R.id.title);
mTitle.setText(mUsername);
mInfo = (TextView) findViewById(R.id.user_info);
mAbout = (TextView) findViewById(R.id.about);
mEmpty = findViewById(R.id.empty);
mTabLayout = (TabLayout) findViewById(R.id.tab_layout);
mTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
// no op
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
// no op
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
scrollToTop();
}
});
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(new SnappyLinearLayoutManager(this, true));
mRecyclerView.addItemDecoration(new CommentItemDecoration(this));
mScrollableHelper = new KeyDelegate.RecyclerViewHelper(mRecyclerView, KeyDelegate.RecyclerViewHelper.SCROLL_ITEM);
if (savedInstanceState != null) {
mUser = savedInstanceState.getParcelable(STATE_USER);
}
if (mUser == null) {
load();
} else {
bind();
}
if (!AppUtils.hasConnection(this)) {
Snackbar.make(findViewById(R.id.content_frame), R.string.offline_notice, Snackbar.LENGTH_LONG).show();
}
}
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 XposedInstaller by rovo89.
the class DownloadDetailsActivity method setupTabs.
private void setupTabs() {
mPager = (ViewPager) findViewById(R.id.download_pager);
mPager.setAdapter(new SwipeFragmentPagerAdapter(getFragmentManager()));
TabLayout mTabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
mTabLayout.setupWithViewPager(mPager);
}
Aggregations