Java Code Examples for android.view.ViewGroup#setId()

The following examples show how to use android.view.ViewGroup#setId() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
protected synchronized final void addRootViewGroup(
    int tag,
    ViewGroup view,
    ThemedReactContext themedContext) {
  if (view.getId() != View.NO_ID) {
    throw new IllegalViewOperationException(
        "Trying to add a root view with an explicit id already set. React Native uses " +
        "the id field to track react tags and will overwrite this field. If that is fine, " +
        "explicitly overwrite the id field to View.NO_ID before calling addRootView.");
  }

  mTagsToViews.put(tag, view);
  mTagsToViewManagers.put(tag, mRootViewManager);
  mRootTags.put(tag, true);
  view.setId(tag);
}
 
Example 2
@Override
public boolean doOnCreate(Bundle bundle) {
    super.doOnCreate(bundle);
    LinearLayout ll = new LinearLayout(this);
    ll.setOrientation(LinearLayout.VERTICAL);
    ViewGroup.LayoutParams mmlp = new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT);
    LinearLayout __ll = new LinearLayout(this);
    __ll.setOrientation(LinearLayout.VERTICAL);
    ViewGroup bounceScrollView = new BounceScrollView(this, null);
    bounceScrollView.setId(R.id.rootBounceScrollView);
    ll.setId(R.id.rootMainLayout);
    //invoke_virtual(bounceScrollView,"a",true,500,500,boolean.class,int.class,int.class);
    bounceScrollView.setLayoutParams(mmlp);
    bounceScrollView.addView(ll, new ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
    //invoke_virtual(bounceScrollView,"setNeedHorizontalGesture",true,boolean.class);
    LinearLayout.LayoutParams fixlp = new LinearLayout.LayoutParams(MATCH_PARENT, dip2px(this, 48));
    RelativeLayout.LayoutParams __lp_l = new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
    int mar = (int) (dip2px(this, 12) + 0.5f);
    __lp_l.setMargins(mar, 0, mar, 0);
    __lp_l.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    __lp_l.addRule(RelativeLayout.CENTER_VERTICAL);
    RelativeLayout.LayoutParams __lp_r = new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
    __lp_r.setMargins(mar, 0, mar, 0);
    __lp_r.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    __lp_r.addRule(RelativeLayout.CENTER_VERTICAL);
    ColorStateList hiColor = ColorStateList.valueOf(Color.argb(255, 242, 140, 72));
    RelativeLayout _t;

    ll.addView(subtitle(this, "QNotified是开源软件,完全免费,无需任何授权/卡密/加群即可使用全部功能,没有卡密或者授权这类的东西,请勿上当受骗!!!"));
    ll.addView(subtitle(this, "如果你希望支持作者, 保持更新的动力, 可请使用以下方式捐赠, 完成后手动打开 [我已捐赠] 即可"));
    ll.addView(subtitle(this, "免费开发不易, 需要花费很多个人精力, 且回报甚微, 甚至有人盗卖, 感谢理解"));
    RelativeLayout iHaveDonated = newListItemSwitchConfig(this, "我已捐赠", null, qn_donated_choice, false);
    ((CompoundButton) iHaveDonated.findViewById(R_ID_SWITCH)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(final CompoundButton buttonView, boolean isChecked) {
            try {
                ConfigManager cfg = ConfigManager.getDefaultConfig();
                cfg.putBoolean(qn_donated_choice, isChecked);
                cfg.save();
                if (isChecked) {
                    showToast(DonateActivity.this, TOAST_TYPE_SUCCESS, "感谢您的支持", Toast.LENGTH_SHORT);
                }
            } catch (Throwable e) {
                log(e);
                showToast(DonateActivity.this, TOAST_TYPE_ERROR, "出了点问题:" + e, Toast.LENGTH_SHORT);
            }
        }
    });
    ll.addView(iHaveDonated);
    ll.addView(subtitle(this, "感谢您的支持!"));
    ll.addView(subtitle(this, ""));
    ll.addView(subtitle(this, "目前还存在一个较为严重的问题:"));
    ll.addView(subtitle(this, "  虽然QNotified是一个完全免费的插件,但仍因有不少人对本软件进行二次贩卖(如:以群发器的名义贩卖),不少人上当受骗"));
    ll.addView(subtitle(this, "从用户反馈来看,这种贩卖情况并非个例"));
    ll.addView(subtitle(this, "这违背了我的本意: **我希望任何个人都能免费的使用本软件**"));
    ll.addView(subtitle(this, "从根本上说,如果任何需要本软件的人都能免费地获取本软件,那么倒卖这种的情况就不会发生"));
    ll.addView(subtitle(this, "所以"));
    ll.addView(subtitle(this, "每多一个人免费地分发本软件,可能因贩卖上当的人就少一个"));
    ll.addView(subtitle(this, "譬如说,可以在各大玩机论坛社区以资源分享的方式分发免费软件(包括但不限于本模块,尽量别设置回复可见)"));
    ll.addView(subtitle(this, "当然以上只是其中一种方法"));
    ll.addView(subtitle(this, "本软件首发地为 https://github.com/cinit/QNotified (求star/issue/pull request)"));
    ll.addView(subtitle(this, "最后,谢谢你的支持"));
    ll.addView(subtitle(this, "by"));
    if (isNiceUser()) ll.addView(newListItemButton(this, "QQ", "点击私信", "1041703712", clickToChat()));
    ll.addView(newListItemButton(this, "Mail", null, "[email protected]", null));
    ll.addView(newListItemButton(this, "Telegram", null, "Auride", clickToUrl("https://t.me/Auride")));
    ll.addView(subtitle(this, "扶贫方式"));
    if (isNiceUser()) ll.addView(newListItemButton(this, "支付宝", null, null, clickToAlipay()));

    ll.addView(subtitle(this, "FAQ1:"));
    ll.addView(subtitle(this, "Q: 捐赠后能解锁隐藏功能吗?"));
    ll.addView(subtitle(this, "A: 不能. 所有功能全部都是可以白嫖的"));
    ll.addView(subtitle(this, "FAQ2:"));
    ll.addView(subtitle(this, "Q: 我捐赠过,但是QQ数据被清除后没了怎么办"));
    ll.addView(subtitle(this, "A: 直接打开 我已捐赠 即可"));
    ll.addView(subtitle(this, "FAQ3:"));
    ll.addView(subtitle(this, "Q: 已知 我已捐赠 这个Switch开和关没有任何区别,那这个开关意义何在"));
    ll.addView(subtitle(this, "A: 和B站上up主的明示投币一个道理"));
    ll.addView(subtitle(this, "FAQ4:"));
    ll.addView(subtitle(this, "Q: 为什么不加个授权验证,然后收费?"));
    ll.addView(subtitle(this, "A: 开源软件搞什么授权验证"));

    //bounceScrollView.setFocusable(true);
    //bounceScrollView.setFocusableInTouchMode(true);
    __ll.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
    this.setContentView(bounceScrollView);
    LinearLayout.LayoutParams _lp_fat = new LinearLayout.LayoutParams(MATCH_PARENT, 0);
    _lp_fat.weight = 1;
    //__ll.addView(bounceScrollView,_lp_fat);
    //sdlv.setBackgroundColor(0xFFAA0000)
    setTitle("捐赠");
    setContentBackgroundDrawable(ResUtils.skin_background);
    //TextView rightBtn=(TextView)invoke_virtual(this,"getRightTextView");
    //log("Title:"+invoke_virtual(this,"getTextTitle"));
    return true;
}
 
Example 3
@Override
public boolean doOnCreate(Bundle bundle) {
    super.doOnCreate(bundle);
    LinearLayout ll = new LinearLayout(this);
    ll.setOrientation(LinearLayout.VERTICAL);
    ViewGroup.LayoutParams mmlp = new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT);
    LinearLayout __ll = new LinearLayout(FakeBatCfgActivity.this);
    __ll.setOrientation(LinearLayout.VERTICAL);
    ViewGroup bounceScrollView = new BounceScrollView(this, null);
    //invoke_virtual(bounceScrollView,"a",true,500,500,boolean.class,int.class,int.class);
    bounceScrollView.setLayoutParams(mmlp);
    bounceScrollView.setId(R.id.rootBounceScrollView);
    ll.setId(R.id.rootMainLayout);
    bounceScrollView.addView(ll, new ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
    //invoke_virtual(bounceScrollView,"setNeedHorizontalGesture",true,boolean.class);
    LinearLayout.LayoutParams fixlp = new LinearLayout.LayoutParams(MATCH_PARENT, dip2px(FakeBatCfgActivity.this, 48));
    RelativeLayout.LayoutParams __lp_l = new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
    int mar = (int) (dip2px(FakeBatCfgActivity.this, 12) + 0.5f);
    __lp_l.setMargins(mar, 0, mar, 0);
    __lp_l.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    __lp_l.addRule(RelativeLayout.CENTER_VERTICAL);
    RelativeLayout.LayoutParams __lp_r = new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
    __lp_r.setMargins(mar, 0, mar, 0);
    __lp_r.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    __lp_r.addRule(RelativeLayout.CENTER_VERTICAL);

    ll.addView(subtitle(FakeBatCfgActivity.this, "!!! 此功能仅在 QQ>=8.2.6 且在线状态为 我的电量 时生效"));
    ll.addView(subtitle(FakeBatCfgActivity.this, "服务器的电量数据有6分钟的延迟属于正常情况"));
    ll.addView(subtitle(FakeBatCfgActivity.this, "请不要把电量设置为 0 ,因为 0 会被TX和谐掉"));
    FakeBatteryHook bat = FakeBatteryHook.get();
    boolean enabled = bat.isEnabled();
    LinearLayout _t;
    ll.addView(_t = subtitle(FakeBatCfgActivity.this, ""));
    tvStatus = (TextView) _t.getChildAt(0);
    ll.addView(subtitle(FakeBatCfgActivity.this, "设置自定义电量百分比:"));
    int _5dp = dip2px(FakeBatCfgActivity.this, 5);
    EditText pct = new EditText(FakeBatCfgActivity.this);
    pct.setId(R_ID_PERCENT_VALUE);
    pct.setInputType(TYPE_CLASS_NUMBER);
    pct.setTextColor(ResUtils.skin_black);
    pct.setTextSize(dip2sp(FakeBatCfgActivity.this, 18));
    pct.setBackgroundDrawable(null);
    pct.setGravity(Gravity.CENTER);
    pct.setPadding(_5dp, _5dp / 2, _5dp, _5dp / 2);
    pct.setBackgroundDrawable(new HighContrastBorder());
    pct.setHint("电量百分比, 取值范围 [1,100]");
    pct.setText(bat.getFakeBatteryCapacity() + "");
    pct.setSelection(pct.getText().length());
    ll.addView(pct, newLinearLayoutParams(MATCH_PARENT, WRAP_CONTENT, 2 * _5dp, _5dp, 2 * _5dp, _5dp));
    CheckBox charging = new CheckBox(FakeBatCfgActivity.this);
    charging.setId(R_ID_CHARGING);
    charging.setText("正在充电");
    charging.setTextSize(17);
    charging.setTextColor(ResUtils.skin_black);
    charging.setButtonDrawable(ResUtils.getCheckBoxBackground());
    charging.setPadding(_5dp, _5dp, _5dp, _5dp);
    charging.setChecked(FakeBatteryHook.get().isFakeBatteryCharging());
    ll.addView(charging, newLinearLayoutParams(MATCH_PARENT, WRAP_CONTENT, 3 * _5dp, _5dp, 2 * _5dp, _5dp));
    Button apply = new Button(FakeBatCfgActivity.this);
    apply.setId(R_ID_APPLY);
    apply.setOnClickListener(this);
    ResUtils.applyStyleCommonBtnBlue(apply);
    ll.addView(apply, newLinearLayoutParams(MATCH_PARENT, WRAP_CONTENT, 2 * _5dp, _5dp, 2 * _5dp, _5dp));
    Button dis = new Button(FakeBatCfgActivity.this);
    dis.setId(R_ID_DISABLE);
    dis.setOnClickListener(this);
    ResUtils.applyStyleCommonBtnBlue(dis);
    dis.setText("停用");
    ll.addView(dis, newLinearLayoutParams(MATCH_PARENT, WRAP_CONTENT, 2 * _5dp, _5dp, 2 * _5dp, _5dp));
    __ll.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
    setContentView(bounceScrollView);
    showStatus();
    setContentBackgroundDrawable(ResUtils.skin_background);
    setTitle("自定义电量");
    return true;
}
 
Example 4
Source Project: espresso-macchiato   File: EspAllOfBuilderTest.java    License: MIT License 5 votes vote down vote up
@Test
public void testWithParentInHierarchy() {
    // hierarchy A
    ViewGroup viewGroupParentA = new LinearLayout(context);
    viewGroupParentA.setId(TEST_PARENT_ID);
    addViewToLayout(viewGroupParentA, BaseActivity.rootLayout);

    ViewGroup viewGroupMidA = new LinearLayout(context);
    viewGroupMidA.setId(TEST_MID_ID);
    addViewToLayout(viewGroupMidA, TEST_PARENT_ID);

    // hierarchy B
    ViewGroup viewGroupParentB = new LinearLayout(context);
    viewGroupParentB.setId(TEST_PARENT_ID + 1);
    addViewToLayout(viewGroupParentB, BaseActivity.rootLayout);

    ViewGroup viewGroupMidB = new LinearLayout(context);
    viewGroupMidB.setId(TEST_MID_ID + 1);
    addViewToLayout(viewGroupMidB, TEST_PARENT_ID + 1);

    // view with same id on both hierarchies
    View viewSameIdA = new View(context);
    View viewSameIdB = new View(context);

    viewSameIdA.setId(TEST_ID);
    viewSameIdB.setId(TEST_ID);

    addViewToLayout(viewSameIdA, TEST_MID_ID);
    addViewToLayout(viewSameIdB, TEST_MID_ID + 1);

    builder.withId(TEST_ID).withParentInHierarchy(TEST_PARENT_ID).build().assertIsDisplayedOnScreen();
}
 
Example 5
private void addInitialChild(StackLayout stackLayout) {
    if (isEmpty()) return;
    ViewGroup child = peek().getView();
    child.setId(CompatUtils.generateViewId());
    peek().addOnAppearedListener(this::startChildrenBellowTopChild);
    presenter.applyInitialChildLayoutOptions(resolveCurrentOptions());
    stackLayout.addView(child, 0, matchParentWithBehaviour(new StackBehaviour(this)));
}
 
Example 6
Source Project: xdroid   File: SettingsActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle state) {
    super.onCreate(state);

    ViewGroup container = new FrameLayout(this);
    container.setId(R.id.container);
    setContentView(container);
}
 
Example 7
private ViewGroup generateLayout() {
    if (ActionBarSherlock.DEBUG) Log.d(TAG, "[generateLayout]");

    // Apply data from current theme.

    TypedArray a = mActivity.getTheme().obtainStyledAttributes(R.styleable.SherlockTheme);

    if (!a.hasValue(R.styleable.SherlockTheme_windowActionBar)) {
        throw new IllegalStateException("You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.");
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowNoTitle, false)) {
        requestFeature(Window.FEATURE_NO_TITLE);
    } else if (a.getBoolean(R.styleable.SherlockTheme_windowActionBar, false)) {
        // Don't allow an action bar if there is no title.
        requestFeature(Window.FEATURE_ACTION_BAR);
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowActionBarOverlay, false)) {
        requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowActionModeOverlay, false)) {
        requestFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
    }

    a.recycle();

    int layoutResource;
    if (!hasFeature(Window.FEATURE_NO_TITLE)) {
        if (hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY)) {
            layoutResource = R.layout.abs__screen_action_bar_overlay;
        } else {
            layoutResource = R.layout.abs__screen_action_bar;
        }
    } else if (hasFeature(Window.FEATURE_ACTION_MODE_OVERLAY) && !hasFeature(Window.FEATURE_NO_TITLE)) {
        layoutResource = R.layout.abs__screen_simple_overlay_action_mode;
    } else {
        layoutResource = R.layout.abs__screen_simple;
    }

    if (ActionBarSherlock.DEBUG) Log.d(TAG, "[generateLayout] using screen XML " + mActivity.getResources().getString(layoutResource));
    View in = mActivity.getLayoutInflater().inflate(layoutResource, null);
    mDecor.addView(in, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));

    ViewGroup contentParent = (ViewGroup)mDecor.findViewById(R.id.abs__content);
    if (contentParent == null) {
        throw new RuntimeException("Couldn't find content container view");
    }

    //Make our new child the true content view (for fragments). VERY VOLATILE!
    mDecor.setId(View.NO_ID);
    contentParent.setId(android.R.id.content);

    if (hasFeature(Window.FEATURE_INDETERMINATE_PROGRESS)) {
        IcsProgressBar progress = getCircularProgressBar(false);
        if (progress != null) {
            progress.setIndeterminate(true);
        }
    }

    return contentParent;
}
 
Example 8
Source Project: android-apps   File: ActionBarSherlockCompat.java    License: MIT License 4 votes vote down vote up
private ViewGroup generateLayout() {
    if (DEBUG) Log.d(TAG, "[generateLayout]");

    // Apply data from current theme.

    TypedArray a = mActivity.getTheme().obtainStyledAttributes(R.styleable.SherlockTheme);

    mIsFloating = a.getBoolean(R.styleable.SherlockTheme_android_windowIsFloating, false);

    if (!a.hasValue(R.styleable.SherlockTheme_windowActionBar)) {
        throw new IllegalStateException("You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.");
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowNoTitle, false)) {
        requestFeature(Window.FEATURE_NO_TITLE);
    } else if (a.getBoolean(R.styleable.SherlockTheme_windowActionBar, false)) {
        // Don't allow an action bar if there is no title.
        requestFeature(Window.FEATURE_ACTION_BAR);
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowActionBarOverlay, false)) {
        requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowActionModeOverlay, false)) {
        requestFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
    }

    a.recycle();

    int layoutResource;
    if (!hasFeature(Window.FEATURE_NO_TITLE)) {
        if (mIsFloating) {
            //Trash original dialog LinearLayout
            mDecor = (ViewGroup)mDecor.getParent();
            mDecor.removeAllViews();

            layoutResource = R.layout.abs__dialog_title_holo;
        } else {
            if (hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY)) {
                layoutResource = R.layout.abs__screen_action_bar_overlay;
            } else {
                layoutResource = R.layout.abs__screen_action_bar;
            }
        }
    } else if (hasFeature(Window.FEATURE_ACTION_MODE_OVERLAY) && !hasFeature(Window.FEATURE_NO_TITLE)) {
        layoutResource = R.layout.abs__screen_simple_overlay_action_mode;
    } else {
        layoutResource = R.layout.abs__screen_simple;
    }

    if (DEBUG) Log.d(TAG, "[generateLayout] using screen XML " + mActivity.getResources().getString(layoutResource));
    View in = mActivity.getLayoutInflater().inflate(layoutResource, null);
    mDecor.addView(in, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));

    ViewGroup contentParent = (ViewGroup)mDecor.findViewById(R.id.abs__content);
    if (contentParent == null) {
        throw new RuntimeException("Couldn't find content container view");
    }

    //Make our new child the true content view (for fragments). VERY VOLATILE!
    mDecor.setId(View.NO_ID);
    contentParent.setId(android.R.id.content);

    if (hasFeature(Window.FEATURE_INDETERMINATE_PROGRESS)) {
        IcsProgressBar progress = getCircularProgressBar(false);
        if (progress != null) {
            progress.setIndeterminate(true);
        }
    }

    return contentParent;
}
 
Example 9
Source Project: zen4android   File: ActionBarSherlockCompat.java    License: MIT License 4 votes vote down vote up
private ViewGroup generateLayout() {
    if (ActionBarSherlock.DEBUG) Log.d(TAG, "[generateLayout]");

    // Apply data from current theme.

    TypedArray a = mActivity.getTheme().obtainStyledAttributes(R.styleable.SherlockTheme);

    if (!a.hasValue(R.styleable.SherlockTheme_windowActionBar)) {
        throw new IllegalStateException("You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.");
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowNoTitle, false)) {
        requestFeature(Window.FEATURE_NO_TITLE);
    } else if (a.getBoolean(R.styleable.SherlockTheme_windowActionBar, false)) {
        // Don't allow an action bar if there is no title.
        requestFeature(Window.FEATURE_ACTION_BAR);
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowActionBarOverlay, false)) {
        requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowActionModeOverlay, false)) {
        requestFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
    }

    a.recycle();

    int layoutResource;
    if (!hasFeature(Window.FEATURE_NO_TITLE)) {
        if (hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY)) {
            layoutResource = R.layout.abs__screen_action_bar_overlay;
        } else {
            layoutResource = R.layout.abs__screen_action_bar;
        }
    } else if (hasFeature(Window.FEATURE_ACTION_MODE_OVERLAY) && !hasFeature(Window.FEATURE_NO_TITLE)) {
        layoutResource = R.layout.abs__screen_simple_overlay_action_mode;
    } else {
        layoutResource = R.layout.abs__screen_simple;
    }

    if (ActionBarSherlock.DEBUG) Log.d(TAG, "[generateLayout] using screen XML " + mActivity.getResources().getString(layoutResource));
    View in = mActivity.getLayoutInflater().inflate(layoutResource, null);
    mDecor.addView(in, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));

    ViewGroup contentParent = (ViewGroup)mDecor.findViewById(R.id.abs__content);
    if (contentParent == null) {
        throw new RuntimeException("Couldn't find content container view");
    }

    //Make our new child the true content view (for fragments). VERY VOLATILE!
    mDecor.setId(View.NO_ID);
    contentParent.setId(android.R.id.content);

    if (hasFeature(Window.FEATURE_INDETERMINATE_PROGRESS)) {
        IcsProgressBar progress = getCircularProgressBar(false);
        if (progress != null) {
            progress.setIndeterminate(true);
        }
    }

    return contentParent;
}
 
Example 10
private ViewGroup generateLayout() {
    if (ActionBarSherlock.DEBUG) Log.d(TAG, "[generateLayout]");

    // Apply data from current theme.

    TypedArray a = mActivity.getTheme().obtainStyledAttributes(R.styleable.SherlockTheme);

    if (!a.hasValue(R.styleable.SherlockTheme_windowActionBar)) {
        throw new IllegalStateException("You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.");
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowNoTitle, false)) {
        requestFeature(Window.FEATURE_NO_TITLE);
    } else if (a.getBoolean(R.styleable.SherlockTheme_windowActionBar, false)) {
        // Don't allow an action bar if there is no title.
        requestFeature(Window.FEATURE_ACTION_BAR);
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowActionBarOverlay, false)) {
        requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowActionModeOverlay, false)) {
        requestFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
    }

    a.recycle();

    int layoutResource;
    if (!hasFeature(Window.FEATURE_NO_TITLE)) {
        if (hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY)) {
            layoutResource = R.layout.abs__screen_action_bar_overlay;
        } else {
            layoutResource = R.layout.abs__screen_action_bar;
        }
    } else if (hasFeature(Window.FEATURE_ACTION_MODE_OVERLAY) && !hasFeature(Window.FEATURE_NO_TITLE)) {
        layoutResource = R.layout.abs__screen_simple_overlay_action_mode;
    } else {
        layoutResource = R.layout.abs__screen_simple;
    }

    if (ActionBarSherlock.DEBUG) Log.d(TAG, "[generateLayout] using screen XML " + mActivity.getResources().getString(layoutResource));
    View in = mActivity.getLayoutInflater().inflate(layoutResource, null);
    mDecor.addView(in, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));

    ViewGroup contentParent = (ViewGroup)mDecor.findViewById(R.id.abs__content);
    if (contentParent == null) {
        throw new RuntimeException("Couldn't find content container view");
    }

    //Make our new child the true content view (for fragments). VERY VOLATILE!
    mDecor.setId(View.NO_ID);
    contentParent.setId(android.R.id.content);

    if (hasFeature(Window.FEATURE_INDETERMINATE_PROGRESS)) {
        IcsProgressBar progress = getCircularProgressBar(false);
        if (progress != null) {
            progress.setIndeterminate(true);
        }
    }

    return contentParent;
}
 
Example 11
private ViewGroup generateLayout() {
    if (ActionBarSherlock.DEBUG) Log.d(TAG, "[generateLayout]");

    // Apply data from current theme.

    TypedArray a = mActivity.getTheme().obtainStyledAttributes(R.styleable.SherlockTheme);

    if (!a.hasValue(R.styleable.SherlockTheme_windowActionBar)) {
        throw new IllegalStateException("You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.");
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowNoTitle, false)) {
        requestFeature(Window.FEATURE_NO_TITLE);
    } else if (a.getBoolean(R.styleable.SherlockTheme_windowActionBar, false)) {
        // Don't allow an action bar if there is no title.
        requestFeature(Window.FEATURE_ACTION_BAR);
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowActionBarOverlay, false)) {
        requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowActionModeOverlay, false)) {
        requestFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
    }

    a.recycle();

    int layoutResource;
    if (!hasFeature(Window.FEATURE_NO_TITLE)) {
        if (hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY)) {
            layoutResource = R.layout.abs__screen_action_bar_overlay;
        } else {
            layoutResource = R.layout.abs__screen_action_bar;
        }
    } else if (hasFeature(Window.FEATURE_ACTION_MODE_OVERLAY) && !hasFeature(Window.FEATURE_NO_TITLE)) {
        layoutResource = R.layout.abs__screen_simple_overlay_action_mode;
    } else {
        layoutResource = R.layout.abs__screen_simple;
    }

    if (ActionBarSherlock.DEBUG) Log.d(TAG, "[generateLayout] using screen XML " + mActivity.getResources().getString(layoutResource));
    View in = mActivity.getLayoutInflater().inflate(layoutResource, null);
    mDecor.addView(in, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));

    ViewGroup contentParent = (ViewGroup)mDecor.findViewById(R.id.abs__content);
    if (contentParent == null) {
        throw new RuntimeException("Couldn't find content container view");
    }

    //Make our new child the true content view (for fragments). VERY VOLATILE!
    mDecor.setId(View.NO_ID);
    contentParent.setId(android.R.id.content);

    if (hasFeature(Window.FEATURE_INDETERMINATE_PROGRESS)) {
        IcsProgressBar progress = getCircularProgressBar(false);
        if (progress != null) {
            progress.setIndeterminate(true);
        }
    }

    return contentParent;
}