此活动已由窗口装饰提供一个操作条。想转移我的东西用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 回答
![?](http://img1.sycdn.imooc.com/545864000001644402200220-100-100.jpg)
慕容708150
TA贡献1831条经验 获得超4个赞
<item name="windowActionBar">false</item>
app/src/main/res/values/styles.xml
.
AppCompatActivity
<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>
![?](http://img1.sycdn.imooc.com/54586425000103f602200220-100-100.jpg)
收到一只叮咚
TA贡献1821条经验 获得超4个赞
Theme.AppCompat.Light.NoActionBar
<style name="NoActionBarTheme" parent="Theme.AppCompat.Light.NoActionBar"> ...</style>
- 3 回答
- 0 关注
- 434 浏览
添加回答
举报
0/150
提交
取消