Search in sources :

Example 31 with TabLayout

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);
        }
    });
}
Also used : View(android.view.View) TextView(android.widget.TextView) ViewPager(android.support.v4.view.ViewPager) WPViewPager(org.wordpress.android.widgets.WPViewPager) KeyEvent(android.view.KeyEvent) TabLayout(android.support.design.widget.TabLayout) TextView(android.widget.TextView) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Example 32 with TabLayout

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);
}
Also used : NavigationView(android.support.design.widget.NavigationView) TabLayout(android.support.design.widget.TabLayout) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) DrawerLayout(android.support.v4.widget.DrawerLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 33 with TabLayout

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();
    }
}
Also used : CommentItemDecoration(io.github.hidroh.materialistic.widget.CommentItemDecoration) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) BottomSheetBehavior(android.support.design.widget.BottomSheetBehavior) TabLayout(android.support.design.widget.TabLayout) SnappyLinearLayoutManager(io.github.hidroh.materialistic.widget.SnappyLinearLayoutManager)

Example 34 with TabLayout

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); */
}
Also used : FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) TabLayout(android.support.design.widget.TabLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 35 with TabLayout

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);
}
Also used : TabLayout(android.support.design.widget.TabLayout)

Aggregations

TabLayout (android.support.design.widget.TabLayout)82 View (android.view.View)36 ViewPager (android.support.v4.view.ViewPager)31 Toolbar (android.support.v7.widget.Toolbar)19 Intent (android.content.Intent)16 TextView (android.widget.TextView)15 ActionBar (android.support.v7.app.ActionBar)12 RecyclerView (android.support.v7.widget.RecyclerView)12 ImageView (android.widget.ImageView)11 Fragment (android.support.v4.app.Fragment)10 NavigationView (android.support.design.widget.NavigationView)8 Test (org.junit.Test)8 Bundle (android.os.Bundle)7 FloatingActionButton (android.support.design.widget.FloatingActionButton)7 UiController (android.support.test.espresso.UiController)7 ViewAction (android.support.test.espresso.ViewAction)7 ViewGroup (android.view.ViewGroup)7 AppBarLayout (android.support.design.widget.AppBarLayout)6 MenuItem (android.view.MenuItem)6 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)5