SoFunction
Updated on 2025-03-03

Two ways to enable actionbar in android

Two methods, the first is the static opening method
Just set the application or activity theme to

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:andro
     package=""
     android:versionCode="1"
     android:versionName="1.0">
  <uses-sdk android:minSdkVersion="18"/>
  <application android:label="@string/app_name" android:icon="@drawable/ic_launcher"
      android:theme="@android:style/">
    <activity android:name="MyActivity"
         android:label="@string/app_name">
      <intent-filter>
        <action android:name=""/>
        <category android:name=""/>
      </intent-filter>
    </activity>
  </application>
</manifest>

The second type is dynamically enabled

import ;
import ;
import ;
import ;

public class MyActivity extends Activity {
  /**
   * Called when the activity is first created.
   */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    (savedInstanceState);
    setContentView();
    ActionBar actionBar = getActionBar();
    ();
  }
}