Settings | Sign in | Sign up

There are currently 2 posts.

菜單動態顯示/隱藏的實例

Floor 1 巨大八爪鱼 5/17/15 9:57
@Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        super.onPrepareOptionsMenu(menu);
        for (int i = 0; i < menu.size(); i++) {
            MenuItem item = menu.getItem(i);
            switch (item.getItemId()) {
            case R.id.action_login:
                item.setEnabled(!App.isLoggedin());
                item.setVisible(!App.isLoggedin());
                break;
            case R.id.action_logout:
                item.setEnabled(App.isLoggedin());
                item.setVisible(App.isLoggedin());
                break;
            }
        }
        return true;
    }
Floor 2 巨大八爪鱼 5/17/15 9:58
item.setEnabled(!App.isLoggedin());
                item.setVisible(!App.isLoggedin());
這兩個可以單獨使用

Content converter:

Reply the post
Content:
User: You are currently anonymous.
Captcha:
Unclear? Try another one.
©2010-2025 Purasbar Ver3.0 [Mobile] [Desktop]
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported license.