Android:How to change the background color of the options menu when selected?
-
I have created an an options menu in my application. I want to change the background color of the menu item selected. Please help me doing this.
-
Answer:
You must try this code which will change your menu color with the menu text. private void setMenuBackground() { // TODO Auto-generated method stub getLayoutInflater().setFactory(new Factory() { @Override public View onCreateView (String name, Context context, AttributeSet attrs) { if (name.equalsIgnoreCase("com.android.internal.view.menu.IconMenuItemView")) { try { LayoutInflater f = getLayoutInflater(); final View view = f.createView(name, null, attrs); new Handler().post( new Runnable() { public void run () { view.setBackgroundColor(Color.GRAY); } }); return view; } catch (InflateException e) { } catch (ClassNotFoundException e) { } } return null; } }); }
Richa at Stack Overflow Visit the source
Related Q & A:
- How to change NetBeans window background color?Best solution by Stack Overflow
- How to change background color in Android application?Best solution by Stack Overflow
- How to make UIImage background color transparent?Best solution by Stack Overflow
- How to draggable button background color to apply another button background?Best solution by Stack Overflow
- How do I change my background color on yahoo?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.