本文整理汇总了Java中android.app.Activity.getActionBar方法的典型用法代码示例。如果您正苦于以下问题:Java Activity.getActionBar方法的具体用法?Java Activity.getActionBar怎么用?Java Activity.getActionBar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.Activity
的用法示例。
在下文中一共展示了Activity.getActionBar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setActionBarUpIndicator
import android.app.Activity; //导入方法依赖的package包/类
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");
}
}
示例2: setActionBarDescription
import android.app.Activity; //导入方法依赖的package包/类
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;
}
示例3: setActionBarUpIndicator
import android.app.Activity; //导入方法依赖的package包/类
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;
}
示例4: getActionBarHeight
import android.app.Activity; //导入方法依赖的package包/类
public static int getActionBarHeight(Activity activity) {
int actionBarHeight = 0;
if(activity.getActionBar()!= null){
actionBarHeight = activity.getActionBar().getHeight();
}
if (actionBarHeight != 0)
return actionBarHeight;
final TypedValue tv = new TypedValue();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
if (activity.getTheme().resolveAttribute(android.support.v7.appcompat.R.attr.actionBarSize, tv, true)){
actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, activity.getResources().getDisplayMetrics());
Log.e("actionBarHeight==",actionBarHeight + "android.support.v7.appcompat.R.attr.actionBarSize");
}
else if (activity.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)){
actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, activity.getResources().getDisplayMetrics());
Log.e("actionBarHeight==",actionBarHeight + "actionBarHeight is android.R.attr.actionBarSize");
}
}
return actionBarHeight;
}
示例5: setActionBarDescription
import android.app.Activity; //导入方法依赖的package包/类
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;
}
示例6: setActionBarDescription
import android.app.Activity; //导入方法依赖的package包/类
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);
}
}
}
示例7: getDisplayHeight
import android.app.Activity; //导入方法依赖的package包/类
public static int getDisplayHeight(Activity activity) {
int height = 0;
if (activity != null && activity.getWindowManager() != null && activity.getWindowManager().getDefaultDisplay() != null) {
Point point=new Point();
activity.getWindowManager().getDefaultDisplay().getSize(point);
height=point.y;
}
Log.e(TAG, "isSupportSmartBar:" + isSupportSmartBar);
if (isSupportSmartBar) {
int smartBarHeight = getSmartBarHeight(activity);
Log.e(TAG, "smartBarHeight:" + smartBarHeight);
height -= smartBarHeight;
}
if (activity != null && activity.getActionBar() != null) {
int actionbar= activity.getActionBar().getHeight();
if(actionbar==0){
TypedArray actionbarSizeTypedArray=activity.obtainStyledAttributes(new int[]{android.R.attr.actionBarSize});
actionbar= (int) actionbarSizeTypedArray.getDimension(0,0);
}
Log.d(TAG, "actionbar:" + actionbar);
height -= actionbar;
}
int status = getStatusBarHeight(activity);
Log.d(TAG, "status:" + status);
height -= status;
Log.d(TAG,"height:"+height);
return height;
}
示例8: getSmartBarHeight
import android.app.Activity; //导入方法依赖的package包/类
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;
}
示例9: ActionBarWrapper
import android.app.Activity; //导入方法依赖的package包/类
public ActionBarWrapper(Activity activity) {
mActivity = activity;
mActionBar = activity.getActionBar();
if (mActionBar != null) {
mActionBar.addOnMenuVisibilityListener(this);
// Fixes issue #746
int displayOptions = mActionBar.getDisplayOptions();
mActionBar.setHomeButtonEnabled((displayOptions & DISPLAY_HOME_AS_UP) != 0);
}
}
示例10: getThemeUpIndicator
import android.app.Activity; //导入方法依赖的package包/类
public static Drawable getThemeUpIndicator(Activity activity) {
Context context;
ActionBar actionBar = activity.getActionBar();
if (actionBar != null) {
context = actionBar.getThemedContext();
} else {
context = activity;
}
TypedArray a = context.obtainStyledAttributes(null, THEME_ATTRS, 16843470, 0);
Drawable result = a.getDrawable(0);
a.recycle();
return result;
}
示例11: postApply
import android.app.Activity; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static void postApply(@NonNull Activity activity, @Nullable String key) {
if (didPreApply == null)
preApply(activity, key);
performMainTheming(activity, key);
final View rootView = getRootView(activity);
final boolean rootSetsToolbarColor = rootView != null && rootView instanceof ViewInterface &&
((ViewInterface) rootView).setsToolbarColor();
if (!rootSetsToolbarColor && Config.coloredActionBar(activity, key)) {
if (activity instanceof AppCompatActivity) {
final AppCompatActivity aca = (AppCompatActivity) activity;
if (aca.getSupportActionBar() != null) {
ViewProcessor toolbarViewProcessor = getViewProcessor(Toolbar.class);
if (toolbarViewProcessor != null) {
// The processor handles retrieving the toolbar from the support action bar
toolbarViewProcessor.process(activity, key, null, null);
}
}
} else if (activity.getActionBar() != null) {
activity.getActionBar().setBackgroundDrawable(new ColorDrawable(Config.toolbarColor(activity, key, null)));
}
}
if (mPostInflationApply != null) {
synchronized (IGNORE_TAG) {
for (View view : mPostInflationApply) {
if (view instanceof PostInflationApplier)
((PostInflationApplier) view).postApply();
else ATE.themeView(activity, view, key);
}
}
}
if (ATEUtil.isInClassPath(MDUtil.MAIN_CLASS))
MDUtil.initMdSupport(activity, key);
}
示例12: fixSmartBar
import android.app.Activity; //导入方法依赖的package包/类
public static void fixSmartBar(Activity activity) {
try {
ActionBar actionBar = activity.getActionBar();
if (actionBar != null) {
actionBar.setActionBarViewCollapsable(true);
}
} catch (NoSuchMethodError e) { // NOSONAR
// do nothing
}
}
示例13: setActionBarUpIndicator
import android.app.Activity; //导入方法依赖的package包/类
public static Object setActionBarUpIndicator(Object info, Activity activity, Drawable drawable, int contentDescRes) {
ActionBar actionBar = activity.getActionBar();
if (actionBar != null) {
actionBar.setHomeAsUpIndicator(drawable);
actionBar.setHomeActionContentDescription(contentDescRes);
}
return info;
}
示例14: setDisplayHomeAsUpEnabled
import android.app.Activity; //导入方法依赖的package包/类
public static void setDisplayHomeAsUpEnabled(Activity activity, boolean b) {
ActionBar actionBar = activity.getActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(b);
}
}
示例15: ChatSDKActionBarHelper
import android.app.Activity; //导入方法依赖的package包/类
public ChatSDKActionBarHelper(Activity activity) {
this.activity = activity;
actionBar = activity.getActionBar();
}