Advertisement
Guest User

change menu background

a guest
Apr 27th, 2010
5,330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. protected void setMenuBackground(){
  2.     getLayoutInflater().setFactory( new Factory() {
  3.        
  4.         @Override
  5.         public View onCreateView ( String name, Context context, AttributeSet attrs ) {
  6.            
  7.             if ( name.equalsIgnoreCase( "com.android.internal.view.menu.IconMenuItemView" ) ) {
  8.                
  9.                 try { // Ask our inflater to create the view
  10.                     LayoutInflater f = getLayoutInflater();
  11.                     final View view = f.createView( name, null, attrs );
  12.                     // Kind of apply our own background
  13.                     new Handler().post( new Runnable() {
  14.                         public void run () {
  15.                             view.setBackgroundResource( R.drawable.menu_background);
  16.                         }
  17.                     } );
  18.                     return view;
  19.                 }
  20.                 catch ( InflateException e ) {
  21.                 }
  22.                 catch ( ClassNotFoundException e ) {
  23.  
  24.                 }
  25.             }
  26.             return null;
  27.         }
  28.     });
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement