简体   繁体   English

弹出菜单显示为空白

[英]Popup menu appears blank

I am working on an app, in which I am want to use a pop-up menu to control some actions and settings. 我正在开发一个应用程序,其中我想使用一个弹出菜单来控制某些操作和设置。 However, when I launch the app in my emulator, the items appear blank, although when I click on them, the action is fired and it works. 但是,当我在模拟器中启动该应用程序时,这些项目显示为空白,尽管当我单击它们时,该操作被触发并且可以正常运行。 Here is a screen of the emulator: 这是模拟器的屏幕:

在此处输入图片说明

I am following the guide, so my code does not differ much from the dev guides, but here is my code: 我遵循该指南,因此我的代码与开发指南没有太大区别,但这是我的代码:

    @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view,
                int position, long ID)
        {
            // TODO Auto-generated method stub

            courseId = ID;
            fields = sqldbase.query(DBHelper.courseTable, new String[] {
                    DBHelper.courseID, DBHelper.courseName,
                    DBHelper.courseProf, DBHelper.averageGrade },
                    DBHelper.courseID + " = " + ID, null, null, null, null);

            PopupMenu popup = new PopupMenu(getBaseContext(), view);
            popup.getMenuInflater().inflate(R.menu.courses_popup_menu,
                    popup.getMenu());   
            popup.show();
            popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener()
            {

                @Override
                public boolean onMenuItemClick(MenuItem item)
                {
                         Log.i(TAG,"OnMenuItemClick Fired");                                                             return false;

                }

            });

            return false;
        }

    });

Could this be related to a problem with themes? 这可能与主题问题有关吗? I have been trying to use a Holo.light.NoTitleBar theme, so in my xml in eclipse, the word Passbook does not show, and everything is white, instead of black. 我一直在尝试使用Holo.light.NoTitleBar主题,因此在Eclipse中的xml中,单词Passbook不会显示,并且所有内容都是白色,而不是黑色。 However, after running in the emulator, the theme is ignored, and this shows up. 但是,在模拟器中运行后,主题将被忽略,并显示出来。

Thanks. 谢谢。

fixed it. 修复。 apparently, popup menus use the attribute android:title instead of android:text. 显然,弹出菜单使用属性android:title而不是android:text。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM