2015-01-26 1 views
-2

각 활동 (.java 파일)에 대한 작업 표시 줄 설정을 시도했지만 하나만 제외하고 각 활동에 대해로드하지 않습니다 (FunnyActivity.java) 누구든지 도와 줄 수 있습니까? 어떤 응답을각 활동에 대해 ActionBar가 표시되지 않음 (하나의 활동에 대해서만 표시)

FunnyActivity.java의 onCreateOptionsMenu

@Override 
public boolean onCreateOptionsMenu(Menu menu) { 
    // Inflate the menu items for use in the action bar 
    MenuInflater inflater = getMenuInflater(); 
    inflater.inflate(R.menu.funny_menu, menu); 
    return super.onCreateOptionsMenu(menu); 
} 

GunsActivity.java의 onCreateOptionsMenu는

@Override 
public boolean onCreateOptionsMenu(Menu menu) { 
    // Inflate the menu items for use in the action bar 
    MenuInflater inflater = getMenuInflater(); 
    inflater.inflate(R.menu.guns_menu, menu); 
    return super.onCreateOptionsMenu(menu); 
} 

감사합니다.

<activity 
     android:name="com.tropicalstudios.soundboard.FunnyActivity" 
     android:label="Funny Sounds" 
     android:theme="@style/Theme.AppCompat.Light.DarkActionBar"> 
     android:launchMode="singleTask" > 
    </activity> 

    <activity 
     android:name="com.tropicalstudios.soundboard.GunsActivity" 
     android:label="Gun Sounds" 
     android:theme="@style/Theme.AppCompat.Light.DarkActionBar" 
     android:launchMode="singleTask" > 
    </activity> 

    <activity 
     android:name="com.tropicalstudios.soundboard.Miscellaneous" 
     android:label="Miscellaneous Sounds" 
     android:theme="@style/Theme.AppCompat.Light.DarkActionBar" 
     android:launchMode="singleTask" > 
    </activity> 
+0

활동 코드는 어디에 있습니까? –

+0

어느 것? 감사합니다 – TropicalStudios

답변

1

를 사용하고 hide();이 그것을 숨길 경우 getActionBar().hide() 또는 getSupportActionBar().hide()를 호출 할 수있는 활동 시도에 액션 바을 숨길 필요합니다. API 수준 7, 8 또는 10을 사용하는 경우 getSupportActionBar()을 사용하고 appcompat-v7 라이브러리를 가져 오는 것을 잊지 마세요. 그런 다음 Activity 대신 ActionBarActivity으로 클래스를 확장하십시오. API 레벨 11 이상인 경우 getActionBar()으로 전화하십시오. 귀하를위한 예가 아래와 같습니다 :

// extend this class with "Activity" for API 11+ 
public class MainActivity extends ActionBarActivity { 

@Override 
protected void onCreate(Bundle savedInstanceState){ 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    // For API 10 and lower only 
    getSupportActionBar().show(); // call hide() if you want to hide it. 

    // For API 11 and higher only 
    getActionBar().show(); // call hide() if you want to hide it. 

ActionBar에 대해 자세히 알아보십시오.

+0

고마워요! 이제 작동합니다! :) – TropicalStudios

0

AndroidManifest 파일은 주어진 활동에 대해 설정 한 스타일을 정의 할 수 있습니다. 이 설정을 수정했거나 하나의 활동에 대한 테마 설정 만있는 경우 다른 활동에는 영향을 미치지 않습니다. 매니페스트 XML 파일에서이 같은 작업 설정이있는 경우 예를 들어, :

<activity android:name=".AlertFailedCommunications" 
      android:label="@string/alert_account_label" 
      android:screenOrientation="portrait" 
      android:theme="@android:style/Theme.Dialog"/> 

는이 대화 스타일의 화면없이 작업 표시 줄이 해당 화면 (안 좋은 예 테마 내에서 사용할 수 있습니다 기대하고 있지만, 아이디어를 얻으십시오). 반면, 다음과 같은 주제는 :

<activity android:name="MainActivity" 
      android:label="@string/app_name" 
      android:screenOrientation="portrait" 
      android:theme="@android:style/Theme.DeviceDefault.Light.DarkActionBar"/> 

과 같은 테마는 어두운 스타일의 액션 바를 제공합니다. 하나를 지원하는 테마를 제공하지 않으면 하나도 볼 수 없습니다. 이것은 당신이 겪고있는 문제 일 수 있습니다.

+0

내 활동에 대한 선언문을 추가했습니다.보세요 ... 도와 주셔서 감사합니다. 이미 테마를 추가 했으므로 제대로로드되지 않은 것 같습니다. – TropicalStudios

1

당신이 보여 show();를 호출하여 ActionBar을 보여/우리는 숨길 수 있습니다 지원 라이브러리

관련 문제