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


Java ActionBarSherlockCompat类代码示例

本文整理汇总了Java中com.actionbarsherlock.internal.ActionBarSherlockCompat的典型用法代码示例。如果您正苦于以下问题:Java ActionBarSherlockCompat类的具体用法?Java ActionBarSherlockCompat怎么用?Java ActionBarSherlockCompat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ActionBarSherlockCompat类属于com.actionbarsherlock.internal包,在下文中一共展示了ActionBarSherlockCompat类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadLogoFromManifest

import com.actionbarsherlock.internal.ActionBarSherlockCompat; //导入依赖的package包/类
/**
 * Attempt to programmatically load the logo from the manifest file of an
 * activity by using an XML pull parser. This should allow us to read the
 * logo attribute regardless of the platform it is being run on.
 *
 * @param activity Activity instance.
 * @return Logo resource ID.
 */
private static int loadLogoFromManifest(Activity activity) {
    int logo = 0;
    try {
        final String thisPackage = activity.getClass().getName();
        if (DEBUG) Log.i(TAG, "Parsing AndroidManifest.xml for " + thisPackage);

        final String packageName = activity.getApplicationInfo().packageName;
        final AssetManager am = activity.createPackageContext(packageName, 0).getAssets();
        final XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml");

        int eventType = xml.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG) {
                String name = xml.getName();

                if ("application".equals(name)) {
                    //Check if the <application> has the attribute
                    if (DEBUG) Log.d(TAG, "Got <application>");

                    for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
                        if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));

                        if ("logo".equals(xml.getAttributeName(i))) {
                            logo = xml.getAttributeResourceValue(i, 0);
                            break; //out of for loop
                        }
                    }
                } else if ("activity".equals(name)) {
                    //Check if the <activity> is us and has the attribute
                    if (DEBUG) Log.d(TAG, "Got <activity>");
                    Integer activityLogo = null;
                    String activityPackage = null;
                    boolean isOurActivity = false;

                    for (int i = xml.getAttributeCount() - 1; i >= 0; i--) {
                        if (DEBUG) Log.d(TAG, xml.getAttributeName(i) + ": " + xml.getAttributeValue(i));

                        //We need both uiOptions and name attributes
                        String attrName = xml.getAttributeName(i);
                        if ("logo".equals(attrName)) {
                            activityLogo = xml.getAttributeResourceValue(i, 0);
                        } else if ("name".equals(attrName)) {
                            activityPackage = ActionBarSherlockCompat.cleanActivityName(packageName, xml.getAttributeValue(i));
                            if (!thisPackage.equals(activityPackage)) {
                                break; //on to the next
                            }
                            isOurActivity = true;
                        }

                        //Make sure we have both attributes before processing
                        if ((activityLogo != null) && (activityPackage != null)) {
                            //Our activity, logo specified, override with our value
                            logo = activityLogo.intValue();
                        }
                    }
                    if (isOurActivity) {
                        //If we matched our activity but it had no logo don't
                        //do any more processing of the manifest
                        break;
                    }
                }
            }
            eventType = xml.nextToken();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (DEBUG) Log.i(TAG, "Returning " + Integer.toHexString(logo));
    return logo;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:79,代码来源:Utility4.java

示例2: onCreate

import com.actionbarsherlock.internal.ActionBarSherlockCompat; //导入依赖的package包/类
@Override
public void onCreate() {
    ActionBarSherlock.unregisterImplementation(ActionBarSherlockNative.class);
    ActionBarSherlock.unregisterImplementation(ActionBarSherlockCompat.class);
    ActionBarSherlock.registerImplementation(HoloActionBarSherlockNative.class);
    ActionBarSherlock.registerImplementation(HoloActionBarSherlockCompat.class);
}
 
开发者ID:WassimBenltaief,项目名称:laposte-android,代码行数:8,代码来源:AddonSherlock.java


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