真正的答案應該是既@zapl和@Himanshu維爾馬尼
對於Android清單組合:
<application
android:name="com.xxx.yyy.Application"
android:debuggable="false"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/Theme.NoTitle"> // remove this line if you have this in your code
<activity
android:name="com.xxx.yyy.Activity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@style/Theme.NoTitle" // remove this line if you have this in your code
android:windowSoftInputMode="adjustResize|stateHidden" >
的活動:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// The Action Bar is a window feature. The feature must be requested
// before setting a content view. Normally this is set automatically
// by your Activity's theme in your manifest. The provided system
// theme Theme.WithActionBar enables this for you. Use it as you would
// use Theme.NoTitleBar. You can add an Action Bar to your own themes
// by adding the element <item name="android:windowActionBar">true</item>
// to your style definition.
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
setContentView(R.layout.activity_main);
// Hide the status bar for Android 4.1 and higher
View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
// Remember that you should never show the action bar if the
// status bar is hidden, so hide that too if necessary.
ActionBar actionBar = getActionBar();
actionBar.hide();
}
參見:HTTP:/ /stackoverflow.com/questions/6867076/getactionbar-returns-null – Harvey 2014-11-05 21:02:47