2013-10-26 2 views
5

일부 옵션이있는 메뉴 버튼 만 필요한 간단한 앱이 있으며 모든 기기에서 작동해야합니다.탐색 모음에 메뉴 버튼을 추가하는 방법

어쨌든, 내 앱은 내비게이션 막대에 메뉴 버튼을 배치 할 수 없다는 것을 제외하고 모든 경우에 정상적으로 작동합니다.

styles.xml 값 폴더 가치 V11의

<style name="AppTheme" parent="AppBaseTheme"> 
    <item name="android:windowNoTitle">true</item>   
</style> 

styles.xml & 값-V14 폴더

<style name="AppTheme" parent="AppBaseTheme"> 
    <item name="android:windowNoTitle">false</item> 
    <item name="android:windowActionBar">true</item> 
    <item name="android:actionBarStyle">@android:style/Widget.Holo.ActionBar</item>   
</style> 

이 코드는 모든에서 onCreate 이벤트에 나타납니다에서 : 여기 내 코드입니다 내 활동

if(Build.VERSION.SDK_INT <= 10 || (Build.VERSION.SDK_INT >= 14 &&  
ViewConfiguration.get(this).hasPermanentMenuKey())) 
{ 
// menu key is present 
ActionBar actionBar = getActionBar(); 
if(actionBar!=null) 
actionBar.hide(); 
} 
else 
{ 
//No menu key 
    ActionBar actionBar = getActionBar(); 
    if(actionBar!=null) 
actionBar.show(); 
} 

이 코드는 작동합니다 괜찮 았어.하지만 액션 바가없는 경우 탐색 바에 메뉴 버튼을 넣고 싶다.

나는 그토록 많은 인터넷 검색을 해왔지만 이것을 위해 어떤 해결책도 찾을 수 없었다.

미리 감사드립니다.

답변

12

아무도 내 질문에 대답하지 않았으므로 나는 그것에 대해 스스로 대답해야했습니다.

먼저 탐색 바의 메뉴 버튼을 활성화하지 않는 것이 좋습니다! 매우이 문서 Say Goodbye To The Menu Button

을 읽을 것을 권장합니다,

 1. Make a simple menu like before 
     2. Not to use an action bar 
     3. Set targetSdkVersion to 13 or below 

: 그리고 당신이 그것을 활성화에 관심이 있다면,

어쨌든 (구글에 의해), 당신이해야 할 것입니다

관련 문제