当前位置: 首页>>代码示例>>Java>>正文


Java Activity.getActionBar方法代码示例

本文整理汇总了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");
        }
    }
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:18,代码来源:ActionBarHelperNative.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:18,代码来源:ActionBarDrawerToggleHoneycomb.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:22,代码来源:ActionBarDrawerToggleHoneycomb.java

示例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;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:27,代码来源:ScreenShot.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:20,代码来源:ActionBarDrawerToggleHoneycomb.java

示例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);
        }
    }
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:12,代码来源:ActionBarHelperNative.java

示例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;
}
 
开发者ID:wangwei123,项目名称:my-weex,代码行数:35,代码来源:CommonUtils.java

示例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;
}
 
开发者ID:wangwei123,项目名称:my-weex,代码行数:16,代码来源:CommonUtils.java

示例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);
    }
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:12,代码来源:ActionBarWrapper.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:ActionBarDrawerToggleJellybeanMR2.java

示例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);
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:39,代码来源:ATE.java

示例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
    }
}
 
开发者ID:brevent,项目名称:prevent,代码行数:11,代码来源:ThemeUtils.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:9,代码来源:ActionBarDrawerToggleJellybeanMR2.java

示例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);
    }
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:7,代码来源:ActionBarHelperNative.java

示例15: ChatSDKActionBarHelper

import android.app.Activity; //导入方法依赖的package包/类
public ChatSDKActionBarHelper(Activity activity) {
    this.activity = activity;
    actionBar = activity.getActionBar();
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:5,代码来源:ChatSDKActionBarHelper.java


注:本文中的android.app.Activity.getActionBar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。