0

Since I am new to android I am not able to figure this out.

I have an app with few layouts. I want to add Action bar on each activity with background image on action bar instead of default color and two action images one on left and one on right.

The here problem get bigger For each activity i need to alter/change image on action bar with change in action. I do not know using third party Action Bar such as Sherlock, Compact, Pleas help and provide code solution link any possible help you can.

Thanks in advance

I forget to mention that i am Using (Android 2.2 Froyo as minimum SDK and Android 4.3 as Compiled as target)

4

1 回答 1

1

Sherlock 动作条示例:

@Override
    public boolean onCreateOptionsMenu(Menu menu) {

            BitmapDrawable bg = (BitmapDrawable) getResources().getDrawable(
                R.drawable.some_background);
        bg.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT);
    getSupportActionBar().setBackgroundDrawable(bg);

        ActionBar actionBar = getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setTitle("some title");

        menu.add(getResources().getString(R.string.some_name))
                .setOnMenuItemClickListener(new OnMenuItemClickListener() {

                    @Override
                    public boolean onMenuItemClick(MenuItem item) {
                            someAction();
                            return false;
                        }
                    }).setIcon(R.drawable.some_icon)
                    .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        }
    }

您可以在每个活动中设置不同的操作栏。

于 2013-09-18T13:00:50.907 回答