为了账号安全,请及时绑定邮箱和手机立即绑定

此活动已由窗口装饰提供一个操作条。

此活动已由窗口装饰提供一个操作条。

明月笑刀无情 2019-06-16 16:05:49
此活动已由窗口装饰提供一个操作条。想转移我的东西用Toolbar而不是动作条,但我一直说错了java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tyczj.weddingalbum/com.xxx.xxx.MainActivity}:  java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request  Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)             at android.app.ActivityThread.access$600(ActivityThread.java:141)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)             at android.os.Handler.dispatchMessage(Handler.java:99)             at android.os.Looper.loop(Looper.java:137)             at android.app.ActivityThread.main(ActivityThread.java:5039)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:511)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)因此,我添加了我的样式,使我的活动没有actionbar。<style name="AppCompatTheme" parent="@style/Theme.AppCompat.Light">         <item name="android:windowActionBar">false</item></style>这个主题适用于我清单中的活动<activity         android:name=".MainActivity"         android:windowSoftInputMode="adjustResize|stateHidden"         android:theme="@style/AppCompatTheme" android:screenOrientation="portrait"/>MainActivity扩展了GooglePlayServiceActivity,所以我也在那里设置了主题<activity        android:name=".GooglePlayServicesActivity"        android:label="@string/title_activity_google_play_services"        android:theme="@style/AppCompatTheme">但我还是明白错误。我也不要求窗口功能在任何地方。知道为什么我还能拿到这个吗?
查看完整描述

3 回答

?
慕容708150

TA贡献1831条经验 获得超4个赞

我认为您正在为AndroidLolliop开发,但无论如何包括以下内容:

<item name="windowActionBar">false</item>

的主题声明app/src/main/res/values/styles.xml.

还有,如果你用AppCompatActivity支持22.1或更高版本的库,添加以下一行:

<item name="windowNoTitle">true</item>

在添加了这些内容之后,您的主题声明可能会如下所示:

<!-- Base application theme. --><style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item></style>


查看完整回答
反对 回复 2019-06-16
?
收到一只叮咚

TA贡献1821条经验 获得超4个赞

另一个简单的方法是让你的主题成为Theme.AppCompat.Light.NoActionBar就像这样:

<style name="NoActionBarTheme" parent="Theme.AppCompat.Light.NoActionBar">
     ...</style>


查看完整回答
反对 回复 2019-06-16
  • 3 回答
  • 0 关注
  • 406 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信