티스토리 뷰

Android의 옵션메뉴의 글씨속성,배경속성등을 변경할 수 있다.

 

 protected void optionsMenuSetMenuBackground()
{
getLayoutInflater().setFactory( new Factory()
{
public View onCreateView ( String name, Context context, AttributeSet attrs )
{
if ( name.equalsIgnoreCase( "com.android.internal.view.menu.IconMenuItemView" ) )
{
try { // Ask our inflater to create the view
// XmlPullParser parser = getResources().getXml(R.layout.custom_menu);
 // AttributeSet attributes = Xml.asAttributeSet(parser);

LayoutInflater f = getLayoutInflater();
final View view = f.createView( name, null, attrs );
new Handler().post( new Runnable() {
public void run () {
// view.setBackgroundColor(Color.argb(242, 0, 20, 60));
view.setBackgroundResource(R.drawable.icon);
}
} );

return view;

}
catch ( InflateException e ) {}
catch ( ClassNotFoundException e ) {}
}
return null;
}
});
}


@Override
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater mi = getMenuInflater();
mi.inflate(R.menu.test_menu, menu);

optionsMenuSetMenuBackground();

return true;
}

 

 

 

[출처및원본] http://comxp.tistory.com/153

 

'Development' 카테고리의 다른 글

[VC++] visual cpp 무료설치  (0) 2012.05.10
[Java] java.math.BigInteger 계산  (1) 2012.05.08
[JQuery] 클릭한 id가 몇번째 id 인지 알아보기  (0) 2012.03.20
[JAXB] JAXB 란?  (0) 2012.02.16
[디자인패턴] 01  (0) 2012.02.05
댓글