0

何が起こったのかわかりませんが、Android Studio でアクションバーのあるアプリを取得できなくなりました。

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    tools:ignore="MergeRootFrame">

    <TextView
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:text="hello"/>
</LinearLayout>

例えば。アクションバーは表示されません。

4

2 に答える 2

0

私はあなたと同じ問題に遭遇しました。あなたのアクティビティは、Androidスタジオで(Activityではなく)ActionBarActivityを拡張させるべきだと思います。

于 2015-03-29T05:09:44.427 に答える
0

これが XML 全体である場合、ノードthemeが欠落しています。例えば:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"
    android:theme="@style/Theme.AppCompat.Light"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    tools:ignore="MergeRootFrame">

    <TextView
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:text="hello"/>
</LinearLayout>

これは、API レベル 11 以上のソリューションです。ここでは、テーマの 1 つを使用しHoloて ActoinBar を追加するだけです。
API レベル 10 以下を使用している場合は、公式ドキュメントを参照してください。

于 2013-10-22T05:24:41.043 に答える