请帮我.
public class TestActivity extends Activity { @OverrIDe protected voID onCreate(Bundle savedInstanceState) { // Todo auto-generated method stub super.onCreate(savedInstanceState); setContentVIEw(R.layout.testing); } /** * Callback when button is clicked to change background * @param v */ public voID onStartClicked(VIEw v) { int Min = 0; int Max = 2; //Random number generator between 0 and 2 inclusive int pos = Min + (int) (Math.random() * ((Max - Min) + 1)); if (pos == 0) { getActionbar().setBackgroundDrawable( getResources().getDrawable(R.drawable.header)); } else if (pos == 1) { getActionbar().setBackgroundDrawable( getResources().getDrawable(R.drawable.inBox_header)); } else if (pos == 2) { getActionbar().setBackgroundDrawable( getResources().getDrawable(R.drawable.outBox_header)); } }}解决方法 最后,我找到了解决方案.在设置背景后通过显示和隐藏动作栏的标题来实现.
getActionbar().setBackgroundDrawable(ContextCompat.getDrawable(this,R.drawable.inBox_header)); actionbar.setdisplayShowTitleEnabled(true);actionbar.setdisplayShowTitleEnabled(false);
谢谢大家的关注.
总结以上是内存溢出为你收集整理的android – Actionbar背景未被更改全部内容,希望文章能够帮你解决android – Actionbar背景未被更改所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)