首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ActionBar.Tab,ActionBar.ITabListener这个类在这个Android平台上已经过时了。

ActionBar.Tab,ActionBar.ITabListener这个类在这个Android平台上已经过时了。
EN

Stack Overflow用户
提问于 2017-03-17 15:18:40
回答 2查看 459关注 0票数 1

ActionBar.Tab,ActionBar.ITabListener这个类在这个安卓平台上被淘汰了,这两个类都过时了。

我怎么知道什么课是新的?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-03-17 23:46:47

代码语言:javascript
复制
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
            xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
 <android.support.v7.widget.Toolbar
   android:id="@+id/toolbar"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:layout_alignParentTop="true"
   android:background="?attr/colorPrimary"
   android:elevation="6dp"
   android:minHeight="?attr/actionBarSize"
   android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
   app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<LinearLayout
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:id="@+id/main_content"
  android:layout_below="@id/toolbar">
<android.support.design.widget.TabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
local:tabMode="scrollable" />
<android.support.v4.view.ViewPager
    android:id="@+id/viewpager"
    android:layout_width="match_parent"
    android:layout_height="0px"
    android:layout_weight="1"
    android:background="@android:color/white" />
</LinearLayout>
</RelativeLayout>

和main.axml

代码语言:javascript
复制
 <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
using MyTabLayout = Android.Support.Design.Widget.TabLayout;

 [Activity(Label = "TabLayout", Theme = "@style/AppTheme", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

         SetContentView (Resource.Layout.Main);


        var tabLayout = FindViewById<MyTabLayout>(Resource.Id.sliding_tabs);
        tabLayout.AddTab(tabLayout.NewTab().SetText("Tab 1"));
        tabLayout.AddTab(tabLayout.NewTab().SetText("Tab 2"));
        tabLayout.AddTab(tabLayout.NewTab().SetText("Tab 3"));
        tabLayout.TabGravity = MyTabLayout.GravityFill;

    }
}
票数 0
EN

Stack Overflow用户

发布于 2017-03-17 15:38:07

您可以使用表布局

使用代码:

代码语言:javascript
复制
 TabLayout tabLayout = ...;
 tabLayout.addTab(tabLayout.newTab().setText("Tab 1"));
 tabLayout.addTab(tabLayout.newTab().setText("Tab 2"));
 tabLayout.addTab(tabLayout.newTab().setText("Tab 3"));

在XMl中:

代码语言:javascript
复制
 <android.support.design.widget.TabLayout
         android:layout_height="wrap_content"
         android:layout_width="match_parent">

     <android.support.design.widget.TabItem
             android:text="@string/tab_text"/>

     <android.support.design.widget.TabItem
             android:icon="@drawable/ic_android"/>

 </android.support.design.widget.TabLayout>

下面是一个示例链接

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42861223

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档