public void setMenuBackground(Context context, Menu menu) {((Activity) context).getLayoutInflater().setFactory(new Factory() {@Overridepublic View onCreateView(String name, Context context,AttributeSet attrs) {if (name.equalsIgnoreCase("com.android.internal.view.menu.IconMenuItemView")) {try {LayoutInflater f = ((Activity) context).getLayoutInflater();final View view = f.createView(name, null, attrs);// 尝试创建我们自己布局new Handler().post(new Runnable() {public void run() {view.setBackgroundResource(R.drawable.menu_bg);// 设置背景为我们自定义的图片,替换cwj_bg文件即可}});return view;} catch (Exception e) {}}return null;}});}

更多相关文章

  1. android 系统中静音后使得音量减键不能解除静音
  2. AndroidStudio使用ViewPagerIndicator
  3. android中字符替换成表情
  4. Ubuntu上安装和使用Android(安卓)Studio
  5. 自定义SeekBar主题
  6. Android(安卓)启动时闪一下黑屏问题的解决办法
  7. Android(安卓)Studio更改SDK或者JDK路径
  8. android 设置linelayout让按钮自动适应屏大小
  9. Android(安卓)fragment在xml中使用没添加ID

随机推荐

  1. android中获得屏幕、视图、任务栏、状态
  2. Android(安卓)onSaveInstanceState和onRe
  3. android开发之interpolator的用法详解
  4. 初学者之Android(安卓)HelloWorld项目
  5. Android(安卓)context源码详解及深入分析
  6. Android的两种数据存储方式分析(一)
  7. Android简单类型资源(Bool、Color、Dimens
  8. android jni介绍
  9. 解决Your content must have a ListView
  10. Android用户注册界面