0

私のアプリケーションでは、2 つのツールバーを追加する必要があります。最初のツールバーには、アプリケーション名と 2 つの他のボタンがあります。次はタブです。アクションバーを使って作成しました。縦表示では問題なく動作します。ただし、横表示では 1 つのツールバーとして表示されます。これらのタブは、最初のバーにスピナー ナビゲーションとして表示されます。ただし、最初のバーの直後に別のバーとして表示する必要があります (縦表示と同じように表示されます)。この問題のため、最初のバーとしてカスタム ツールバーを作成しようとしました。しかし今、私は次のように例外を取得しています:

01-30 11:05:59.385: E/AndroidRuntime(2712): FATAL EXCEPTION: main
01-30 11:05:59.385: E/AndroidRuntime(2712): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.androidtest/com.example.androidtest.HomeActivity}: android.util.AndroidRuntimeException: You cannot combine custom titles with other title features

これは私がアクティビティで使用したコードです:

private ActionBar actionBar;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.activity_main);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
}

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater=getMenuInflater();
        inflater.inflate(R.menu.main, menu);
        return super.onCreateOptionsMenu(menu);
    }

window_title.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="35dip"
    android:gravity="center_vertical"
    android:background="@android:color/darker_gray">

    <ImageView 
        android:id="@+id/header" 
        android:background="@drawable/ic_launcher"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"/>

    <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:text="Custom Window Text"
        android:textColor="@android:color/black"
        android:textStyle="bold"/>

    <Button
        android:id="@+id/titlebutton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

</LinearLayout>

この問題を解決するにはどうすればよいですか、または縦向きと横向きの両方のビューで 2 つのツールバーを並べて作成するにはどうすればよいですか?

4

0 に答える 0