Android Studio:ActionBar.TabListener不适用于AppCompatActivity吗? [英] Android Studio: ActionBar.TabListener does not work with AppCompatActivity?

查看:334
本文介绍了Android Studio:ActionBar.TabListener不适用于AppCompatActivity吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于不推荐使用,我正在尝试将某些代码从FragmentActivity升级到AppCompatActivity,并将ActionBar升级到android.support.v7.app.ActionBar。我花了几个小时来解决这个问题,但是我相信有更多经验的人也许可以很快解决这个问题。

I am trying to upgrade some code from FragmentActivity to AppCompatActivity and ActionBar to android.support.v7.app.ActionBar due to deprecation. I've spent a few hours trying to fix this, but I am sure someone with more experience might be able to solve this very quickly.

所以我的课程看起来像这样现在:

So my class looks like this now:

import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
//...many other imports here
public class MyClass extends AppCompatActivity implements ActionBar.TabListener{

@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
//other code here...
}

我的问题是我遇到了错误,因为Android Studio无法识别超类中的onTabSelected方法签名。将选项卡参数更改为 Tab选项卡而不是 ActionBar.Tab选项卡也无济于事。

My problem is that I am getting an error because Android Studio does not recognize the onTabSelected method signature in the superclass. Changing the tab paramenter to simply "Tab tab" instead of "ActionBar.Tab tab" doesn't help either.

有人有任何想法吗?

推荐答案

就像我说的那样,它已被弃用。

Like i said, it is deprecated.

请参阅: http:// developer。 android.com/intl/zh-CN/reference/android/support/v7/app/ActionBar.TabListener.html


不推荐使用此界面。 不推荐使用
操作栏导航模式,并且内联工具栏操作栏不支持该导航模式。考虑使用其他常用导航模式来代替

This interface is deprecated. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead.

关于您的问题:


操作栏标签可以替换为:


  • TabLayout Android设计支持库中获取,无论是否带有
    ViewPager ;或

  • TabLayout from the Android Design Support Library, with or without a ViewPager; or

a ViewPager 和您最喜欢的其他标签解决方案,无论
PagerTabStrip 任意数量的第三方标签实现 ;或

a ViewPager and your favorite other tab solution for it, whether that be PagerTabStrip or any number of third-party tab implementations; or

FragmentTabHost

检查此链接: ActionBarActivity和ActionBar.TabListener在Android Tab片段(Eclipse ApI 22)中已弃用

这篇关于Android Studio:ActionBar.TabListener不适用于AppCompatActivity吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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