當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。