本文介绍了如何改变背景颜色弹出式菜单中的android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我生成菜单从查询数据库中的每个选项。这里是我的链接到源$ C $ C: http://pastebin.com/f918BMz1 。一切都是好的,但问题是如何改变选项菜单或弹出式菜单的背景色(从黑到白)的颜色,这可能吗?
I generate each option of menu from querying database.Here is my link to the source code: http://pastebin.com/f918BMz1 .Everything is okay, but the problem is how to change color of option menu or background color of popup menu (from black to white), Is it possible ?
final PopupMenu popupMenu = new PopupMenu(getBaseContext(),v);
SQLiteDatabase db = AdapterDb.getReadableDatabase();
Cursor cursor = db.rawQuery(sql, null); int ctritem=0;
if (cursor.moveToFirst()) {
popupMenu.getMenu().add(Menu.NONE, ctritem, Menu.NONE, "ALL ITEMS");
do {
ctritem++;
popupMenu.getMenu().add(Menu.NONE, ctritem, Menu.NONE, cursor.getString(0)); }
while (cursor.moveToNext());
}
感谢
推荐答案
添加弹出菜单样式UR AppTheme:
Add popupMenu style to ur AppTheme:
<style name="AppTheme" parent="android:Theme.Light">
<item name="android:popupMenuStyle">@style/PopupMenu</item>
</style>
<style name="PopupMenu" parent="@android:style/Widget.PopupMenu">
<item name="android:popupBackground">@android:color/white</item>
</style>
manifest.xml的:
manifest.xml:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
.............
</application>
这篇关于如何改变背景颜色弹出式菜单中的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!