2015-05-06 180 views
0

作爲Android Studio的初學者,我有一個主要活動,它具有啓動選項卡活動的圖像按鈕。 我添加使用選項卡式活動中的隱藏選項卡標題

一個新的活動右鍵點擊>新建>活動>選項卡式活動

它創建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" /> 

當我運行的應用程序,並觸及的ImageButton和分頁活動開始,其結果是: enter image description here

當我從右向左輕掃,看來我有3個選項卡具有相同的圖片。 我不知道爲什麼沒有標籤標題,爲什麼有三個標籤具有相同的內容,如何創建標題和更改標籤內容? 我的主題是Theme.AppCombat.Light.DarkActionBar

任何幫助,將不勝感激。

回答

0

到你的清單中添加它爲每個活動: 機器人:主題=「@安卓風格/ Theme.NoTitleBar.Fullscreen」

+0

當我這行添加到在AndroidManifest.xml活動,應用程序不運行並關閉「不幸的是,應用程序已停止。」 – SalmanShariati

+0

05-06 21:59:04.453 21810-21810/com.webraya.t0.t0 E/AndroidRuntime:致命例外:main java.lang.RuntimeException:無法啓動活動ComponentInfo {com.webraya.t0.t0/com .webraya.t0.t0.ActivityNameT1}:java.lang.IllegalStateException:您需要在此活動中使用Theme.AppCompat主題(或後代)。 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2308) ...... – SalmanShariati

相關問題