不同的动作栏项目(按钮/图)为每个活动 [英] Different Action Bar Items (Button/Image) for each Activity
问题描述
由于我是新到Android,我无法想出解决办法。
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.
这里的问题得到更大的对于每一个活动,我需要改变与行动改变操作栏上/改变形象。
我不知道使用第三方操作栏,如福尔摩斯,结构紧凑,
普莱斯提供帮助和code解决方案链接任何可能的帮助,您可以。
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.
在此先感谢
我忘了提,我使用(的Android 2.2 Froyo作为最小的SDK和Android 4.3的编译为目标)
I forget to mention that i am Using (Android 2.2 Froyo as minimum SDK and Android 4.3 as Compiled as target)
推荐答案
福尔摩斯操作栏示例:
@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);
}
}
您可以在每个活动设置不同的动作条。
You can set different action bars in each activity.
这篇关于不同的动作栏项目(按钮/图)为每个活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!