Search in sources :

Example 66 with TabLayout

use of android.support.design.widget.TabLayout in project MaterialDateTimePicker by wdullaer.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    adapter = new PickerAdapter(getFragmentManager());
    viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setAdapter(adapter);
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
    for (int i = 0; i < adapter.getCount(); i++) tabLayout.getTabAt(i).setText(adapter.getTitle(i));
}
Also used : TabLayout(android.support.design.widget.TabLayout)

Example 67 with TabLayout

use of android.support.design.widget.TabLayout in project SeeSik by GHHM.

the class Evaluation method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_evaluation);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    fCalendar = new Calendar_main();
    fDailyEvaluation = new DailyEvaluation();
    fRecommend = new Recommend();
    getSupportFragmentManager().beginTransaction().replace(R.id.container, fDailyEvaluation).commit();
    TabLayout tabs = (TabLayout) findViewById(R.id.tabs);
    tabs.addTab(tabs.newTab().setText("일일평가"));
    tabs.addTab(tabs.newTab().setText("월별평가"));
    tabs.addTab(tabs.newTab().setText("추천음식"));
    tabs.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {

        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            int position = tab.getPosition();
            Log.d("Evaluation", " 선택된 탭: " + position);
            Fragment selected = null;
            if (position == 0) {
                selected = fDailyEvaluation;
            } else if (position == 1) {
                selected = fCalendar;
            } else if (position == 2) {
                selected = fRecommend;
            }
            getSupportFragmentManager().beginTransaction().replace(R.id.container, selected).commit();
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {
        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {
        }
    });
}
Also used : Calendar_main(org.androidtown.myapplication.calendar.Calendar_main) TabLayout(android.support.design.widget.TabLayout) Fragment(android.support.v4.app.Fragment) ActionBar(android.support.v7.app.ActionBar)

Example 68 with TabLayout

use of android.support.design.widget.TabLayout in project AndroidDevelop by 7449.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabLayout);
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager);
    mData = new ArrayList<>();
    mData.add("一");
    mData.add("二");
    mData.add("三");
    mData.add("四");
    mData.add("五");
    mData.add("六");
    mData.add("七");
    TabNameAdapter tabNameAdapter = new TabNameAdapter(getSupportFragmentManager());
    viewPager.setAdapter(tabNameAdapter);
    tabLayout.setupWithViewPager(viewPager);
}
Also used : TabLayout(android.support.design.widget.TabLayout) ViewPager(android.support.v4.view.ViewPager)

Example 69 with TabLayout

use of android.support.design.widget.TabLayout in project ride-read-android by Ride-Read.

the class TimeLineFragment method initView.

private void initView(View v) {
    final TabLayout tablayout = (TabLayout) v.findViewById(R.id.main_timeline_tablayout);
    tablayout.setSelectedTabIndicatorColor(ContextCompat.getColor(getContext(), R.color.colorPrimary));
    LinearLayout linearLayout = (LinearLayout) tablayout.getChildAt(0);
    linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
    linearLayout.setDividerPadding(20);
    linearLayout.setDividerDrawable(ContextCompat.getDrawable(getContext(), R.drawable.timleline_tablayout_divider));
    initViewPager(v);
    tablayout.setupWithViewPager(viewPager);
    for (int i = 0; i < tablayout.getTabCount(); i++) {
        TabLayout.Tab tab = tablayout.getTabAt(i);
        tab.setText(tabTitle[i]);
    }
    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            tablayout.setScrollPosition(position, positionOffset, true);
        }

        @Override
        public void onPageSelected(int position) {
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    tablayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {

        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            viewPager.setCurrentItem(tab.getPosition());
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {
        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {
        }
    });
}
Also used : TabLayout(android.support.design.widget.TabLayout) ViewPager(android.support.v4.view.ViewPager) LinearLayout(android.widget.LinearLayout)

Example 70 with TabLayout

use of android.support.design.widget.TabLayout in project Tusky by Vavassor.

the class AccountListFragment method onDestroyView.

@Override
public void onDestroyView() {
    if (jumpToTopAllowed()) {
        TabLayout tabLayout = (TabLayout) getActivity().findViewById(R.id.tab_layout);
        tabLayout.removeOnTabSelectedListener(onTabSelectedListener);
    }
    super.onDestroyView();
}
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