选项卡式活动

时间:2015-05-06 17:11:28

标签: java android android-activity android-studio tabs

作为Android Studio的初学者,我有一个带有图像按钮的主要活动,可以启动Tabbed活动。 我已经使用

添加了一项新活动

右键点击>新>活动>选项卡式活动

它创建activity_tabbed.xml和fragment_tabbed.xml

fragmented_tabbed.xml contgains:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context="com.webraya.t0.t0.Tabbed$PlaceholderFragment">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageView"
        android:src="@drawable/a"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" />
</RelativeLayout>

和activity_tabbed.xml包含:

<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/pager"
android:layout_width="match_parent" android:layout_height="match_parent"
tools:context="com.webraya.t0.t0.Tabbed" />

当我运行应用程序并触摸图像按钮并启动Tabbed活动时,结果是: enter image description here

当我从右向左滑动时,似乎我有3个带有相同图片的标签。 我不知道为什么没有标签标题,为什么有三个标签具有相同的内容,如何创建标题和更改标签内容? 我的主题是Theme.AppCombat.Light.DarkActionBar

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:0)

进入您的清单为每个活动添加它:  android:theme =“@ android:style / Theme.NoTitleBar.Fullscreen”