Android UI How to - Setup Standard ActionBar








Question

We would like to know how to setup Standard ActionBar.

Answer

import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
//from  ww  w.j av  a2 s .c o  m
public class Main {
  @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
  public static void setupStandardActionBar(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
      activity.getActionBar().setDisplayHomeAsUpEnabled(true);
    }
  }
}