我是Android开发的新手,正在开发溢出菜单。为此我必须更改我的应用程序的主题,以便包含溢出菜单的操作栏可见。
但是android studio并没有使用操作栏渲染任何主题。
我在互联网上搜索解决方案,并在stackoverflow上找到一个说我必须更新我的res / values / styles.xml文件。我更新了名为AppTheme的标签,但它并没有解决我的问题。
我试图使缓存无效并重新启动但仍未解决。我还尝试清理项目并重建它。没有任何效果。
我附上了错误的屏幕截图。 请帮助。
这是我的styles.xml文件:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Base.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>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
的AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.naveenjain.test3">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
答案 0 :(得分:0)
根据问题:You need to use a Theme.AppCompat theme (or descendant) with this activity 您需要按照以下步骤操作:
您遇到此问题的原因是您的活动 尝试应用对话框主题是在扩展
ActionBarActivity
这需要应用AppCompat
主题。将Java继承从
ActionBarActivity
更改为Activity
和 将对话框主题保留在清单中。
检查上面的链接以获取更多解决方案
希望有所帮助