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));
}
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) {
}
});
}
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);
}
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) {
}
});
}
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();
}
Aggregations