如何更改android中操作栏上的图标

时间:2015-06-29 06:01:13

标签: android-actionbar

我创建了一个滑动菜单,我想用(...)打开它,但我尝试了很多来改变(&lt ;-)的图标。 这是我的代码。

 mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
                    R.drawable.ic_drawer1, //nav menu toggle icon
                    R.string.app_name, // nav drawer open - description for accessibility
                    R.string.app_name // nav drawer close - description for accessibility
            ) {
                public void onDrawerClosed(View view) {
                    getActionBar().setTitle("hello");
                    // calling onPrepareOptionsMenu() to show action bar icons
                    invalidateOptionsMenu();
                }

                public void onDrawerOpened(View drawerView) {
                    getActionBar().setTitle("ohhh");
                    // calling onPrepareOptionsMenu() to hide action bar icons
                    invalidateOptionsMenu();
                }
            };

         //   getSupportActionBar().setDisplayShowHomeEnabled(true);

       //     getActionBar().setHomeButtonEnabled(true);
            //getSupportActionBar().setIcon(R.drawable.ic_drawer1);

          getSupportActionBar().setIcon(R.drawable.ic_drawer1);
            getSupportActionBar().setDisplayUseLogoEnabled(true);
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);

1 个答案:

答案 0 :(得分:0)

已经有人问过了。尝试更改清单文件以更改您的应用徽标,或者如果它不起作用,请尝试此链接。 Android: How to change the ActionBar "Home" Icon to be something other than the app icon?。这可能有所帮助。