Use Action Bar
Description
Action Bar is located at the top of the device's screen, it displays the application icon together with the activity title.
To turn off the action bar in manifest xml file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.java2s.MyActionBar"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="14" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".MyActionBarActivity"
android:theme="@android:style/Theme.Holo.NoActionBar" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
To hide the action bar in code
import android.app.ActionBar;
import android.app.Activity;
import android.os.Bundle;
/*from w w w .j av a 2 s . c o m*/
public class MyActionBarActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ActionBar actionBar = getActionBar();
actionBar.hide();
//actionBar.show(); //show it again
}
}
If you use the android:theme attribute to turn off the Action Bar, calling the getActionBar() method returns a null during runtime.