Java 类android.app.ActionBar 实例源码

项目:Perfect-Day    文件:LoginActivity.java   
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    View decorView = getWindow().getDecorView();
    int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    decorView.setSystemUiVisibility(uiOptions);
    ActionBar actionBar = getActionBar();
    if (null != actionBar) actionBar.hide();
    ButterKnife.bind(this);
    FirebaseAuth auth = FirebaseAuth.getInstance();
    if (auth.getCurrentUser() != null) {
        showWhiteSnackBar(R.string.sign_in_successful);
        googleLoginButton.setVisibility(View.INVISIBLE);
        Intent intent = new Intent(getApplicationContext(), MainActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
        finish();
    }

}
项目:buildAPKsSamples    文件:MainActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if(savedInstanceState != null) {
        if (savedInstanceState.getInt("theme", -1) != -1) {
          mThemeId = savedInstanceState.getInt("theme");
          this.setTheme(mThemeId);
        }
        mTitlesHidden = savedInstanceState.getBoolean("titlesHidden");
    }

    setContentView(R.layout.main);

    ActionBar bar = getActionBar();
    bar.setDisplayShowTitleEnabled(false);

    ContentFragment frag = (ContentFragment) getFragmentManager()
            .findFragmentById(R.id.content_frag);
    if (frag != null) mDualFragments = true;

    if (mTitlesHidden) {
        getFragmentManager().beginTransaction()
                .hide(getFragmentManager().findFragmentById(R.id.titles_frag)).commit();
    }
}
项目:boohee_v5.6    文件:ActionBarDrawerToggleHoneycomb.java   
public static SetIndicatorInfo setActionBarDescription(SetIndicatorInfo info, Activity activity, int contentDescRes) {
    if (info == null) {
        info = new SetIndicatorInfo(activity);
    }
    if (info.setHomeAsUpIndicator != null) {
        try {
            ActionBar actionBar = activity.getActionBar();
            info.setHomeActionContentDescription.invoke(actionBar, new Object[]{Integer.valueOf(contentDescRes)});
            if (VERSION.SDK_INT <= 19) {
                actionBar.setSubtitle(actionBar.getSubtitle());
            }
        } catch (Exception e) {
            Log.w(TAG, "Couldn't set content description via JB-MR2 API", e);
        }
    }
    return info;
}
项目:ThunderMusic    文件:PreferencesActivity.java   
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
    this.setTheme(R.style.SettingsTheme);

    super.onCreate(savedInstanceState);

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setIcon(R.drawable.null_icon);
    if (InterfaceUtils.getTabletMode(this)) {
        addPreferencesFromResource(R.xml.preferences_tab);
    } else {
        addPreferencesFromResource(R.xml.preferences);
    }
}
项目:boohee_v5.6    文件:ActionBarDrawerToggleHoneycomb.java   
public static SetIndicatorInfo setActionBarUpIndicator(SetIndicatorInfo info, Activity activity, Drawable drawable, int contentDescRes) {
    info = new SetIndicatorInfo(activity);
    if (info.setHomeAsUpIndicator != null) {
        try {
            ActionBar actionBar = activity.getActionBar();
            info.setHomeAsUpIndicator.invoke(actionBar, new Object[]{drawable});
            info.setHomeActionContentDescription.invoke(actionBar, new Object[]{Integer.valueOf(contentDescRes)});
        } catch (Exception e) {
            Log.w(TAG, "Couldn't set home-as-up indicator via JB-MR2 API", e);
        }
    } else if (info.upIndicatorView != null) {
        info.upIndicatorView.setImageDrawable(drawable);
    } else {
        Log.w(TAG, "Couldn't set home-as-up indicator");
    }
    return info;
}
项目:Ships    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // FIXME: Observed exception "IllegalAccessException (@MainActivity:onCreate:16) {main}"

       // Init some singletons which need the Context
       Analytics.getInstance().init(this);
       SettingsUtils.getInstance().init(this);

    setContentView(R.layout.activity_main);

    final ActionBar actionBar=getActionBar();
    if (actionBar!=null) {
           actionBar.setDisplayShowTitleEnabled(true);
           //actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
       }

       final IntentFilter filter=new IntentFilter();
       filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
       filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
       registerReceiver(usbReceiver,filter);
}
项目:ultrasonic    文件:ActionBarHelperNative.java   
public static void setActionBarUpIndicator(Object info, Activity activity, Drawable drawable, int contentDescRes) {

        final SetIndicatorInfo sii = (SetIndicatorInfo) info;
        if (sii.setHomeAsUpIndicator != null) {
            try {
                final ActionBar actionBar = activity.getActionBar();
                sii.setHomeAsUpIndicator.invoke(actionBar, drawable);
                sii.setHomeActionContentDescription.invoke(actionBar, contentDescRes);
            } catch (Throwable t) {
                if (ActionBarHelper.DEBUG) Log.e(TAG, "Couldn't set home-as-up indicator via JB-MR2 API", t);
            }
        } else if (sii.upIndicatorView != null) {
            sii.upIndicatorView.setImageDrawable(drawable);
        } else {
            if (ActionBarHelper.DEBUG) Log.e(TAG, "Couldn't set home-as-up indicator");
        }
    }
项目:boohee_v5.6    文件:ActionBarDrawerToggleHoneycomb.java   
public static Object setActionBarDescription(Object info, Activity activity, int contentDescRes) {
    SetIndicatorInfo setIndicatorInfo;
    if (info == null) {
        setIndicatorInfo = new SetIndicatorInfo(activity);
    }
    SetIndicatorInfo sii = setIndicatorInfo;
    if (sii.setHomeAsUpIndicator != null) {
        try {
            ActionBar actionBar = activity.getActionBar();
            sii.setHomeActionContentDescription.invoke(actionBar, new Object[]{Integer.valueOf(contentDescRes)});
            if (VERSION.SDK_INT <= 19) {
                actionBar.setSubtitle(actionBar.getSubtitle());
            }
        } catch (Exception e) {
            Log.w(TAG, "Couldn't set content description via JB-MR2 API", e);
        }
    }
    return setIndicatorInfo;
}
项目:Perfect-Day    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    View decorView = getWindow().getDecorView();
    int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    decorView.setSystemUiVisibility(uiOptions);
    ActionBar actionBar = getActionBar();
    if (null != actionBar) actionBar.hide();
    mBottomBar.setOnTabSelectListener(
            new OnTabSelectListener() {
                @Override
                public void onTabSelected(@IdRes int tabId) {
                    Fragment fragment;
                    switch (tabId) {
                        case R.id.bot_bar_today:
                            fragment = new TodayTasksFragment();
                            break;
                        case R.id.bot_bar_list:
                            fragment = new ListTasksFragment();
                            break;
                        case R.id.bot_bar_more:
                            fragment = new MoreInfoFragment();
                            break;
                        default:
                            fragment = new TodayTasksFragment();
                    }
                    FragmentManager fragmentManager = getSupportFragmentManager();
                    FragmentTransaction ft = fragmentManager.beginTransaction();
                    ft.replace(R.id.flContent, fragment, fragment.getClass().getName());
                    ft.commit();
                }
            });
}
项目:duo-navigation-drawer    文件:DuoDrawerToggleHoneycomb.java   
public static SetIndicatorInfo setActionBarDescription(SetIndicatorInfo info, Activity activity,
                                                       int contentDescRes) {
    if (info == null) {
        info = new SetIndicatorInfo(activity);
    }
    if (info.setHomeAsUpIndicator != null) {
        try {
            final ActionBar actionBar = activity.getActionBar();
            info.setHomeActionContentDescription.invoke(actionBar, contentDescRes);
            if (Build.VERSION.SDK_INT <= 19) {
                // For API 19 and earlier, we need to manually force the
                // action bar to generate a new content description.
                actionBar.setSubtitle(actionBar.getSubtitle());
            }
        } catch (Exception e) {
            Log.w(TAG, "Couldn't set content description via JB-MR2 API", e);
        }
    }
    return info;
}
项目:diary    文件:SettingsFragment.java   
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
                                     Preference preference)
{
    boolean result =
        super.onPreferenceTreeClick(preferenceScreen, preference);

    // Set home as up
    if (preference instanceof PreferenceScreen)
    {
        Dialog dialog = ((PreferenceScreen)preference).getDialog();
        ActionBar actionBar = dialog.getActionBar();
        actionBar.setDisplayHomeAsUpEnabled(false);
    }

    return result;
}
项目:boohee_v5.6    文件:ActionBarDrawerToggleHoneycomb.java   
public static Object setActionBarUpIndicator(Object info, Activity activity, Drawable drawable, int contentDescRes) {
    SetIndicatorInfo setIndicatorInfo;
    if (info == null) {
        setIndicatorInfo = new SetIndicatorInfo(activity);
    }
    SetIndicatorInfo sii = setIndicatorInfo;
    if (sii.setHomeAsUpIndicator != null) {
        try {
            ActionBar actionBar = activity.getActionBar();
            sii.setHomeAsUpIndicator.invoke(actionBar, new Object[]{drawable});
            sii.setHomeActionContentDescription.invoke(actionBar, new Object[]{Integer.valueOf(contentDescRes)});
        } catch (Exception e) {
            Log.w(TAG, "Couldn't set home-as-up indicator via JB-MR2 API", e);
        }
    } else if (sii.upIndicatorView != null) {
        sii.upIndicatorView.setImageDrawable(drawable);
    } else {
        Log.w(TAG, "Couldn't set home-as-up indicator");
    }
    return setIndicatorInfo;
}
项目:yaacc-code    文件:ImageViewerActivity.java   
private void menuBarsHide() {
    Log.d(getClass().getName(), "menuBarsHide");
    ActionBar actionBar = getActionBar();
    if (actionBar == null) {
        Log.d(getClass().getName(), "menuBarsHide ActionBar is null");
        return;
    }

    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().clearFlags(
            WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LOW_PROFILE);
    actionBar.hide(); // slides out
}
项目:GeekZone    文件:AppUtils.java   
public static View makeDoneCancelLayout(int layoutId,
                                        LayoutInflater layoutInflater,
                                        int doneId,
                                        View.OnClickListener onDoneListener,
                                        int cancelId,
                                        View.OnClickListener onCancelListener) {
    @SuppressLint("InflateParams")
    LinearLayout doneDiscardLayout = (LinearLayout) layoutInflater.inflate(layoutId,
            null);
    doneDiscardLayout.setLayoutParams(new ActionBar.LayoutParams(
            ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT));
    doneDiscardLayout.findViewById(doneId)
            .setOnClickListener(onDoneListener);
    doneDiscardLayout.findViewById(cancelId)
            .setOnClickListener(onCancelListener);
    return doneDiscardLayout;
}
项目:GitHub    文件:ActionBarHelper.java   
public static void setTitle(android.support.v7.app.ActionBar actionBar, SpannableString spannableString) {
    // BUGFIX
    // @see http://stackoverflow.com/questions/7658725/android-java-lang-illegalargumentexception-invalid-payload-item-type
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN && Build.MANUFACTURER.toUpperCase().equals("LGE")) {
        actionBar.setTitle(spannableString.toString());
    } else {
        actionBar.setTitle(spannableString);
    }
}
项目:PADC-MyanmarAttractions-AC    文件:AttractionListActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_attraction_list);
    ButterKnife.bind(this, this);

    setActionBar(toolbar);

    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setTitle(getString(R.string.app_title_mm));
    }

    mAttractionAdapter = new AttractionAdapter(getApplicationContext(), this);
    rvAttractions.setAdapter(mAttractionAdapter);

    LinearLayoutManager verticalSingleColumnLM = new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.VERTICAL, false);
    rvAttractions.setLayoutManager(verticalSingleColumnLM);

    mAttractionsModel = ViewModelProviders.of(this).get(AttractionsModel.class);
    mAttractionsModel.initDatabase(getApplicationContext());
    mAttractionsModel.getAttractions().observe(this, new Observer<List<AttractionVO>>() {
        @Override
        public void onChanged(@Nullable List<AttractionVO> attractionVOs) {
            mAttractionAdapter.setNewData(attractionVOs);
        }
    });
}
项目:FCM-for-Mojo    文件:MainSettingsFragment.java   
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    ActionBar actionBar = getActivity().getActionBar();
    if (actionBar != null) {
        actionBar.setTitle(R.string.activity_name);
        actionBar.setDisplayHomeAsUpEnabled(false);
    }
}
项目:AOSP-Kayboard-7.1.2    文件:SettingsActivity.java   
@Override
protected void onCreate(final Bundle savedState) {
    super.onCreate(savedState);
    final ActionBar actionBar = getActionBar();
    final Intent intent = getIntent();
    if (actionBar != null) {
        mShowHomeAsUp = intent.getBooleanExtra(EXTRA_SHOW_HOME_AS_UP, true);
        actionBar.setDisplayHomeAsUpEnabled(mShowHomeAsUp);
        actionBar.setHomeButtonEnabled(mShowHomeAsUp);
    }
    StatsUtils.onSettingsActivity(
            intent.hasExtra(EXTRA_ENTRY_KEY) ? intent.getStringExtra(EXTRA_ENTRY_KEY)
                    : EXTRA_ENTRY_VALUE_SYSTEM_SETTINGS);
}
项目:RetroMusicPlayer    文件:SystemUiHelperImplHC.java   
protected void onSystemUiHidden() {
    ActionBar ab = mActivity.getActionBar();
    if (ab != null) {
        ab.hide();
    }

    mActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setIsShowing(false);
}
项目:boohee_v5.6    文件:ActionBarDrawerToggle.java   
public Context getActionBarThemedContext() {
    ActionBar actionBar = this.mActivity.getActionBar();
    if (actionBar != null) {
        return actionBar.getThemedContext();
    }
    return this.mActivity;
}
项目:ultrasonic    文件:ActionBarHelperNative.java   
public static void setActionBarDescription(Object info, Activity activity, int contentDescRes) {
    final SetIndicatorInfo sii = (SetIndicatorInfo) info;
    if (sii.setHomeAsUpIndicator != null) {
        try {
            final ActionBar actionBar = activity.getActionBar();
            sii.setHomeActionContentDescription.invoke(actionBar, contentDescRes);
        } catch (Throwable t) {
            if (ActionBarHelper.DEBUG) Log.e(TAG, "Couldn't set content description via JB-MR2 API", t);
        }
    }
}
项目:cwac-crossport    文件:ActionBarDrawerToggle.java   
@Override
public void setActionBarUpIndicator(Drawable drawable, int contentDescRes) {
  final ActionBar actionBar = mActivity.getActionBar();
  if (actionBar != null) {
    actionBar.setHomeAsUpIndicator(drawable);
    actionBar.setHomeActionContentDescription(contentDescRes);
  }
}
项目:martian-cli    文件:CommonUtils.java   
private static int getSmartBarHeight(Activity activity) {
    ActionBar actionbar = activity.getActionBar();
    if (actionbar != null)
        try {
            Class c = Class.forName("com.android.internal.R$dimen");
            Object obj = c.newInstance();
            Field field = c.getField("mz_action_button_min_height");
            int height = Integer.parseInt(field.get(obj).toString());
            return activity.getResources().getDimensionPixelSize(height);
        } catch (Exception e) {
            e.printStackTrace();
            actionbar.getHeight();
        }
    return 0;
}
项目:adyen-android    文件:CheckoutActivity.java   
public void setActionBarTitle(String title) {
    ActionBar actionBar = getActionBar();
    if (actionBar != null && actionBar.getCustomView() != null) {
        ((TextView) actionBar.getCustomView().findViewById(R.id.action_bar_title)).setText(title);
        actionBar.show();
    }
}
项目:PhoneFoneFun    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ActionBar b = getActionBar();
    if (b!=null) b.hide();

    display = (TextView) findViewById(R.id.display);
    switchPhone = (Switch) findViewById(R.id.switchPhone);

    hellos = getResources().getStringArray(R.array.hello);
    byes = getResources().getStringArray(R.array.bye);
    convos = getResources().getStringArray(R.array.convo);

    mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);

    mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);


    findViewById(R.id.about_link).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent about = new Intent(MainActivity.this, AboutActivity.class);
            startActivity(about);
        }
    });


}
项目:bluetooth-chat-appliction    文件:BluetoothChatFragment.java   
/**
 * Updates the status on the action bar.
 *
 * @param subTitle status
 */
private void setStatus(CharSequence subTitle) {
    FragmentActivity activity = getActivity();
    if (null == activity) {
        return;
    }
    final ActionBar actionBar = activity.getActionBar();
    if (null == actionBar) {
        return;
    }
    actionBar.setSubtitle(subTitle);
}
项目:LuaViewPlayground    文件:UDNavigation.java   
private void setupActionBarDrawable(Drawable drawable) {
    if (drawable != null) {
        final ActionBar actionBar = LuaViewUtil.getActionBar(getGlobals());
        if (actionBar != null) {
            actionBar.setBackgroundDrawable(drawable);
        }
    }
}
项目:LuaViewPlayground    文件:UDNavigation.java   
@Override
public Varargs invoke(Varargs args) {
    final ActionBar actionBar = LuaViewUtil.getActionBar(getGlobals());
    if (actionBar != null) {
    }
    return UDNavigation.this;
}
项目:diary    文件:Settings.java   
@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    // Get preferences
    SharedPreferences preferences =
        PreferenceManager.getDefaultSharedPreferences(this);

    boolean darkTheme =
        preferences.getBoolean(Diary.PREF_DARK_THEME, false);

    if (darkTheme)
        setTheme(R.style.AppDarkTheme);

    // Display the fragment as the main content.
    getFragmentManager().beginTransaction()
    .replace(android.R.id.content, new SettingsFragment())
    .commit();

    // Enable back navigation on action bar
    ActionBar actionBar = getActionBar();
    if (actionBar != null)
    {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setTitle(R.string.settings);
    }
}
项目:LuaViewPlayground    文件:UDActionBar.java   
@Override
public Varargs invoke(Varargs args) {
    final ActionBar actionBar = LuaViewUtil.getActionBar(getGlobals());
    if (actionBar != null) {
        final boolean showBack = args.optboolean(2, true);
        actionBar.setDisplayHomeAsUpEnabled(showBack);
    }
    return UDActionBar.this;
}
项目:Daejeon-People    文件:Setting.java   
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.chat_list_listview);

        final ActionBar chatting = getActionBar();
//        chatting.setCustomView(R.layout.custom_chat_list);
        chatting.setDisplayShowTitleEnabled(false);
        chatting.setDisplayShowCustomEnabled(true);
        chatting.setDisplayShowHomeEnabled(false);

        backBtn = (Button) findViewById(R.id.backBtn);
    }
项目:boohee_v5.6    文件:ActionBarDrawerToggleJellybeanMR2.java   
public static Object setActionBarDescription(Object info, Activity activity, int contentDescRes) {
    ActionBar actionBar = activity.getActionBar();
    if (actionBar != null) {
        actionBar.setHomeActionContentDescription(contentDescRes);
    }
    return info;
}
项目:SmartRC    文件:BluetoothChatFragment.java   
private void setStatus(CharSequence subTitle) {
    FragmentActivity activity = getActivity();
    if (null == activity) {
        return;
    }
    final ActionBar actionBar = activity.getActionBar();
    if (null == actionBar) {
        return;
    }
    actionBar.setSubtitle(subTitle);
}
项目:iconsole-android    文件:BluetoothChatFragment.java   
/**
 * Updates the status on the action bar.
 *
 * @param subTitle status
 */
private void setStatus(CharSequence subTitle) {
    FragmentActivity activity = getActivity();
    if (null == activity) {
        return;
    }
    final ActionBar actionBar = activity.getActionBar();
    if (null == actionBar) {
        return;
    }
    actionBar.setSubtitle(subTitle);
}
项目:BilibiliClient    文件:BangumiScheduleActivity.java   
@Override
public void initToolBar() {
    mToolbar.setTitle("番剧时间表");
    setSupportActionBar(mToolbar);
    ActionBar actionBar = getActionBar();
    if (actionBar != null)
        actionBar.setDisplayHomeAsUpEnabled(true);
}
项目:OSS-purple-06    文件:HomeActivity.java   
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home_view);
    callbackManager  = CallbackManager.Factory.create();
    shareDialog = new ShareDialog(this);

    //타이틀바의 글자를 중앙으로 만들기위해서 CustomBar를 제작.
    this.getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    this.getSupportActionBar().setCustomView(R.layout.home_titlebar);

    //CardNews View
    cardNewsList = new ArrayList<CardNewsItem>();
    RecyclerView rv = (RecyclerView) findViewById(R.id.rv);

    rv.setHasFixedSize(true);

    //layoutManager
    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
    rv.setLayoutManager(layoutManager);

    //카드 리스트뷰 어댑터에 연결
    adapter = new CardNewsAdapter(this, cardNewsList);
    rv.setAdapter(adapter);

    adapter.notifyDataSetChanged();

    Toast.makeText(getApplicationContext(), this.getIntent().getStringExtra("userName")+"님 환영합니다.",Toast.LENGTH_SHORT).show();

}
项目:duo-navigation-drawer    文件:DuoDrawerToggle.java   
@Override
public Context getActionBarThemedContext() {
    final ActionBar actionBar = mActivity.getActionBar();
    final Context context;
    if (actionBar != null) {
        context = actionBar.getThemedContext();
    } else {
        context = mActivity;
    }
    return context;
}
项目:duo-navigation-drawer    文件:DuoDrawerToggle.java   
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
@Override
public void setActionBarUpIndicator(Drawable drawable, int contentDescRes) {
    final ActionBar actionBar = mActivity.getActionBar();
    if (actionBar != null) {
        actionBar.setHomeAsUpIndicator(drawable);
        actionBar.setHomeActionContentDescription(contentDescRes);
    }
}
项目:CommonFramework    文件:RecyclerViewExample.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.recyclerview);
    recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        ActionBar actionBar = getActionBar();
        if (actionBar != null) {
            actionBar.setTitle("RecyclerView");
        }
    }

    // Layout Managers:
    recyclerView.setLayoutManager(new LinearLayoutManager(this));

    // Item Decorator:
    recyclerView.addItemDecoration(new DividerItemDecoration(getResources().getDrawable(R.drawable.divider)));
    recyclerView.setItemAnimator(new DefaultItemAnimator());

    // Adapter:
    String[] adapterData = new String[]{"Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"};
    mDataSet = new ArrayList<String>(Arrays.asList(adapterData));
    mAdapter = new RecyclerViewAdapter(this, recyclerView, mDataSet);
    ((RecyclerViewAdapter) mAdapter).setMode(Attributes.Mode.Single);
    recyclerView.setAdapter(mAdapter);

    try {
        new ItemTouchBuilder()
                .setList(mDataSet)
                .setAdapter(mAdapter)
                .setSwappable(false)
                .create(recyclerView)
                .attachToRecyclerView(recyclerView);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:simple-keyboard    文件:SettingsActivity.java   
@Override
protected void onCreate(final Bundle savedState) {
    super.onCreate(savedState);
    final ActionBar actionBar = getActionBar();
    final Intent intent = getIntent();
    if (actionBar != null) {
        mShowHomeAsUp = intent.getBooleanExtra(EXTRA_SHOW_HOME_AS_UP, true);
        actionBar.setDisplayHomeAsUpEnabled(mShowHomeAsUp);
        actionBar.setHomeButtonEnabled(mShowHomeAsUp);
    }
}