本文整理汇总了Java中android.support.design.widget.TabLayout.setOnTabSelectedListener方法的典型用法代码示例。如果您正苦于以下问题:Java TabLayout.setOnTabSelectedListener方法的具体用法?Java TabLayout.setOnTabSelectedListener怎么用?Java TabLayout.setOnTabSelectedListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.design.widget.TabLayout
的用法示例。
在下文中一共展示了TabLayout.setOnTabSelectedListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateView
import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_notebook_tabs, container, false);
mViewPagerAdapter = new MyViewPagerAdapter(getActivity());
ViewPager viewPager = (ViewPager) view.findViewById(R.id.pager);
viewPager.setAdapter(mViewPagerAdapter);
mTabs = (TabLayout) view.findViewById(R.id.tabs);
mTabs.post(new Runnable() {
@Override
public void run() {
mTabs.setTabsFromPagerAdapter(mViewPagerAdapter);
}
});
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabs));
mTabs.setOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(viewPager));
return view;
}
示例2: initView
import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
protected void initView() {
findViewById(R.id.iv_github).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openMyGitHub();
}
});
mPagerBehavior = (UcNewsHeaderPagerBehavior) ((CoordinatorLayout.LayoutParams) findViewById(R.id.id_uc_news_header_pager).getLayoutParams()).getBehavior();
mPagerBehavior.setPagerStateListener(this);
mNewsPager = (ViewPager) findViewById(R.id.id_uc_news_content);
mTableLayout = (TabLayout) findViewById(R.id.id_uc_news_tab);
mFragments = new ArrayList<TestFragment>();
for (int i = 0; i < 4; i++) {
mFragments.add(TestFragment.newInstance(String.valueOf(i), false));
mTableLayout.addTab(mTableLayout.newTab().setText("Tab" + i));
}
mTableLayout.setTabMode(TabLayout.MODE_FIXED);
mTableLayout.setOnTabSelectedListener(this);
mNewsPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTableLayout));
mNewsPager.setAdapter(new TestFragmentAdapter(mFragments, getSupportFragmentManager()));
}
示例3: onCreate
import android.support.design.widget.TabLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_project_view);
framework = new App_Framework(this);
//ACCESS THE PASSED PARAMETERS FROM GUI_adaptr.java
this.projectUniqueID = getIntent().getStringExtra("project_view_unique_ID");
this.projectTitle = getIntent().getStringExtra("project_view_title");
//check if the value of ID and title is null, if so, exit the application and output error message
if(this.projectUniqueID.isEmpty() || this.projectTitle.isEmpty())
{
finish();
Log.e("Unexpected Error", "Project Title or ID is NULL");
System.exit(0);
}
setTitle(this.projectTitle);
Bundle bundle = new Bundle();
bundle.putString("title", this.projectTitle);
bundle.putString("id", this.projectUniqueID);
mainView.setArguments(bundle);
projectViewFragmentAdapter = new projectView_fragmentPagerAdapter(getSupportFragmentManager());
viewPager = (ViewPager) findViewById(R.id.viewPager_projectView);
setupViewPager(viewPager);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
tabLayout.setOnTabSelectedListener(tabSelectedListener);
//this disables the back button at the upper left screen
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
}