本文整理匯總了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);
}