使用Toolbar.OnClickListener代替ActionBar.TabListener? [英] Use Toolbar.OnClickListener instead of ActionBar.TabListener?

查看:989
本文介绍了使用Toolbar.OnClickListener代替ActionBar.TabListener?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Andr​​oid和最近使用的是Android模板(标签式活动 - 与ViewPager和片段),并注意到,动作条和ActionBar.TabListener是德precated。所以,我更换了动作条与AppCompatActivity的建议,但现在我想知道我应该怎么用,而不是TabListener。我可以使用onClickListener嵌套类的工具栏类?

I am new to android and recently used a android template (Tabbed activity - with ViewPager and fragments) and noticed that the ActionBar and ActionBar.TabListener are deprecated. So I replaced the ActionBar with AppCompatActivity as it is recommended, but Now I am wondering what should I use instead of the TabListener. Can I use onClickListener nested class in the Toolbar class ?

节点:该应用程序正常工作与去precated接口,但我想用一个界面,是不是

Node: The app works fine with the deprecated interface, but I want to use an interface that is not.

public class MainActivity extends AppCompatActivity implements ActionBar.TabListener {

这是我的应用程序的截图

This is a screenshot of my app

推荐答案

我会建议你使用材料设计标签。它将使用ViewPager几乎相同。其优点是,材料标签是实际的标签。

I would recommend you to use Material Design tabs. It will use ViewPager and almost same. The advantage is, Material tabs are actual tabs.

当您使用ActionBar.TabListener(德precated),它实际上不是标签。他们实际上是动作条的标签,这..如果你旋转屏幕,它就会自动把自己的动作条之上。在这里阅读文档

When you use ActionBar.TabListener (deprecated), it is not actually tabs. They are actually actionbar tabs, which.. if you will rotate the screen, it will place themselves automatically on ActionBar on top. read the documentation here

添加导航标签

所以,实现材料的设计,这是新的标签和最佳的解决方案。
在开始之前,我想这是最好的教程

So implement Material Design, which is new and best solution for tabs. To get started, i guess this is the best tutorial

材料设计标签

Material Design Tabs

这篇关于使用Toolbar.OnClickListener代替ActionBar.TabListener?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆