Java Code Examples for android.widget.LinearLayout#removeView()

The following examples show how to use android.widget.LinearLayout#removeView() . 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
Source File: AdvancedSettingsActivity.java    From alpha-wallet-android with MIT License 6 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)
{
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    switch (requestCode)
    {
        case HomeActivity.RC_ASSET_EXTERNAL_WRITE_PERM:
            if (viewModel.createDirectory())
            {
                LinearLayout advancedSettingsLayout = findViewById(R.id.layout);
                advancedSettingsLayout.removeView(tokenScript);
                showAlphaWalletDirectoryConfirmation();
                //need to set up the listener
                viewModel.startFileListeners();
            }
            break;
    }
}
 
Example 2
Source File: RewriteAlertController.java    From FoodOrdering with Apache License 2.0 6 votes vote down vote up
private void setupContent(LinearLayout contentPanel) {
	mScrollView = (ScrollView) mWindow.findViewById(R.id.scrollView);
	mScrollView.setFocusable(false);
	mTextMessage = (TextView) mWindow.findViewById(R.id.message);

	if (mTextMessage == null) {
		return;
	} else if (!TextUtils.isEmpty(message)) {
		mTextMessage.setText(message);
	} else {
		mTextMessage.setVisibility(View.GONE);
		mScrollView.removeView(mTextMessage);
		if (mListView != null) {
			contentPanel.removeView(mScrollView);
			contentPanel.addView(mListView, new LinearLayout.LayoutParams(
					LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
			contentPanel.setLayoutParams(new LinearLayout.LayoutParams(
					LayoutParams.MATCH_PARENT, 0, 1.0f));
		} else {
			contentPanel.setVisibility(View.GONE);
		}
	}
}
 
Example 3
Source File: DialogBuilder.java    From HeadsUp with GNU General Public License v2.0 6 votes vote down vote up
private View createSkeleton() {
    LayoutInflater inflater = (LayoutInflater) mContext
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout rootLayout = (LinearLayout) inflater.inflate(
            R.layout.dialog_main_skeleton, new FrameLayout(mContext), false);
    TextView titleView = (TextView) rootLayout.findViewById(R.id.title);

    if (Device.hasLollipopApi()) {
        // The dividers are quite ugly with material design.
        rootLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_NONE);
    }

    if (mTitleText == null && mIcon == null) {
        rootLayout.removeView(titleView);
    } else {
        if (mTitleText != null)
            titleView.setText(mTitleText);
        if (mIcon != null)
            titleView.setCompoundDrawablesWithIntrinsicBounds(mIcon, null, null, null);
    }

    return rootLayout;
}
 
Example 4
Source File: MsgViewHolderBase.java    From NIM_Android_UIKit with MIT License 6 votes vote down vote up
private void setContent() {
    if (!isShowBubble() && !isMiddleItem()) {
        return;
    }

    LinearLayout bodyContainer = (LinearLayout) view.findViewById(R.id.message_item_body);

    // 调整container的位置
    int index = isReceivedMessage() ? 0 : 4;
    if (bodyContainer.getChildAt(index) != contentContainer) {
        bodyContainer.removeView(contentContainer);
        bodyContainer.addView(contentContainer, index);
    }

    if (isMiddleItem()) {
        setGravity(bodyContainer, Gravity.CENTER);
    } else {
        if (isReceivedMessage()) {
            setGravity(bodyContainer, Gravity.LEFT);
            contentContainer.setBackgroundResource(leftBackground());
        } else {
            setGravity(bodyContainer, Gravity.RIGHT);
            contentContainer.setBackgroundResource(rightBackground());
        }
    }
}
 
Example 5
Source File: AppDialog.java    From Android_framework with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private LinearLayout generateLayout(String text){
    LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.dialog_item_button_layout, null);
    View v_line = layout.findViewById(R.id.v_line);
    TextView tv_text = (TextView) layout.findViewById(R.id.tv_text);
    tv_text.setText(text);
    if (ll_bottom_button.getChildCount() == 0){
        layout.removeView(v_line);
        tv_text.setBackgroundResource(R.drawable.dialog_button_bottom_selector);
    }
    else if (ll_bottom_button.getChildCount() == 1){
        tv_text.setBackgroundResource(R.drawable.dialog_button_bottomright_selector);
    }
    else{
        tv_text.setBackgroundResource(R.drawable.dialog_button_bottomright_selector);
    }
    reBuildCircle();
    LinearLayout.LayoutParams params =
            new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    params.weight = 1;
    layout.setLayoutParams(params);
    layout.setOnClickListener(this);
    return layout;
}
 
Example 6
Source File: AlertDialog.java    From LLApp with Apache License 2.0 6 votes vote down vote up
private void setupContent(LinearLayout contentPanel) {
    this.mScrollView = (ScrollView)this.findViewById(R.id.scrollView);
    this.mScrollView.setFocusable(false);
    this.mMessageView = (TextView)this.findViewById(R.id.message);
    if(this.mMessageView != null) {
        if(this.mMessage != null) {
            this.mMessageView.setText(this.mMessage);
        } else {
            this.mMessageView.setVisibility(8);
            this.mScrollView.removeView(this.mMessageView);
            if(this.mListView != null) {
                contentPanel.removeView(this.findViewById(R.id.scrollView));
                contentPanel.addView(this.mListView, new android.widget.LinearLayout.LayoutParams(-1, -1));
                contentPanel.setLayoutParams(new android.widget.LinearLayout.LayoutParams(-1, 0, 1.0F));
            } else {
                contentPanel.setVisibility(8);
            }
        }

    }
}
 
Example 7
Source File: MultiVideoCallActivity.java    From sealtalk-android with MIT License 5 votes vote down vote up
@Override
public void onRemoteUserLeft(String userId, RongCallCommon.CallDisconnectedReason reason) {
    //incoming状态,localViewUserId为空
    if (localViewUserId == null)
        return;
    if (localViewUserId.equals(userId)) {
        localViewContainer.removeAllViews();
        String currentUserId = RongIMClient.getInstance().getCurrentUserId();
        FrameLayout remoteVideoView = (FrameLayout) remoteViewContainer.findViewWithTag(currentUserId);
        localView = (SurfaceView) remoteVideoView.getChildAt(0);
        remoteVideoView.removeAllViews();
        localViewContainer.addView(localView);
        TextView topUserNameView = (TextView) topContainer.findViewById(R.id.rc_voip_user_name);
        UserInfo userInfo = RongContext.getInstance().getUserInfoFromCache(currentUserId);
        if (userInfo != null) {
            topUserNameView.setText(userInfo.getName());
        } else {
            topUserNameView.setText(currentUserId);
        }
        localViewUserId = currentUserId;
    }

    View singleRemoteView = remoteViewContainer.findViewWithTag(userId + "view");

    if (singleRemoteView == null)
        return;

    LinearLayout container = (LinearLayout) singleRemoteView.getParent();
    container.removeView(singleRemoteView);
    if (container.equals(remoteViewContainer2)) {
        if (remoteViewContainer1.getChildCount() > 0) {
            View childView = remoteViewContainer1.getChildAt(0);
            remoteViewContainer1.removeView(childView);
            remoteViewContainer2.addView(childView);
        }
    }
}
 
Example 8
Source File: MainPagerFragment.java    From Awesome-WanAndroid with Apache License 2.0 5 votes vote down vote up
private void initRecyclerView() {
    mFeedArticleDataList = new ArrayList<>();
    mAdapter = new ArticleListAdapter(R.layout.item_search_pager, mFeedArticleDataList);
    mAdapter.setOnItemClickListener((adapter, view, position) -> startArticleDetailPager(view, position));
    mAdapter.setOnItemChildClickListener((adapter, view, position) -> clickChildEvent(view, position));
    mRecyclerView.setLayoutManager(new LinearLayoutManager(_mActivity));
    mRecyclerView.setHasFixedSize(true);
    //add head banner
    LinearLayout mHeaderGroup = ((LinearLayout) LayoutInflater.from(_mActivity).inflate(R.layout.head_banner, null));
    mBanner = mHeaderGroup.findViewById(R.id.head_banner);
    mHeaderGroup.removeView(mBanner);
    mAdapter.addHeaderView(mBanner);
    mRecyclerView.setAdapter(mAdapter);
}
 
Example 9
Source File: RongHorizontalScrollView.java    From sealtalk-android with MIT License 5 votes vote down vote up
public void removeLayoutChildView(View v) {
    if (v == null) return;

    View view = getChildAt(0);

    if (view != null) {
        if (view instanceof LinearLayout) {
            LinearLayout layout = (LinearLayout) view;
            layout.removeView(v);
        }
    }
}
 
Example 10
Source File: AbsFragment.java    From Aria with Apache License 2.0 5 votes vote down vote up
/**
 * 显示占位布局
 *
 * @param type {@link TempView#ERROR}
 * {@link TempView#DATA_NULL}
 * {@link TempView#LOADING}
 */
protected void showTempView(int type) {
  if (mTempView == null || !useTempView) {
    return;
  }
  mTempView.setType(type);
  if (mParent != null) {
    int size = ViewGroup.LayoutParams.MATCH_PARENT;
    ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(size, size);
    if (mParent instanceof ViewPager) {
      //                ViewPager vp = (ViewPager) mParent;
      //                int position = vp.getCurrentItem();
      //                View child = vp.getChildAt(position);
      //                L.d(TAG, "hashcode ==> " + child.hashCode());
      View child = mRootView;
      if (child != null) {
        if (child instanceof LinearLayout) {
          LinearLayout ll = (LinearLayout) child;
          ll.removeView(mTempView);
          ll.addView(mTempView, 0, lp);
        } else if (child instanceof RelativeLayout || child instanceof FrameLayout) {
          ViewGroup vg = (ViewGroup) child;
          vg.removeView(mTempView);
          vg.addView(mTempView, lp);
        } else {
          L.e(TAG, "框架的填充只支持,LinearLayout、RelativeLayout、FrameLayout");
        }
      }
    } else {
      mParent.removeView(mTempView);
      mParent.addView(mTempView, lp);
    }
  }
}
 
Example 11
Source File: InfoBarControlLayout.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a standard toggle switch and adds it to the layout.
 *
 * -------------------------------------------------
 * | ICON | MESSAGE                       | TOGGLE |
 * -------------------------------------------------
 * If an icon is not provided, the ImageView that would normally show it is hidden.
 *
 * @param iconResourceId ID of the drawable to use for the icon, or 0 to hide the ImageView.
 * @param iconColorId    ID of the tint color for the icon, or 0 for default.
 * @param toggleMessage  Message to display for the toggle.
 * @param toggleId       ID to use for the toggle.
 * @param isChecked      Whether the toggle should start off checked.
 */
public View addSwitch(int iconResourceId, int iconColorId, CharSequence toggleMessage,
        int toggleId, boolean isChecked) {
    LinearLayout switchLayout = (LinearLayout) LayoutInflater.from(getContext()).inflate(
            R.layout.infobar_control_toggle, this, false);
    addView(switchLayout, new ControlLayoutParams());

    ImageView iconView = (ImageView) switchLayout.findViewById(R.id.control_icon);
    if (iconResourceId == 0) {
        switchLayout.removeView(iconView);
    } else {
        iconView.setImageResource(iconResourceId);
        if (iconColorId != 0) {
            iconView.setColorFilter(
                    ApiCompatibilityUtils.getColor(getResources(), iconColorId));
        }
    }

    TextView messageView = (TextView) switchLayout.findViewById(R.id.control_message);
    messageView.setText(toggleMessage);

    SwitchCompat switchView =
            (SwitchCompat) switchLayout.findViewById(R.id.control_toggle_switch);
    switchView.setId(toggleId);
    switchView.setChecked(isChecked);

    return switchLayout;
}
 
Example 12
Source File: SuntimesConfigActivity0.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
public void moveSectionToTop(int sectionLayoutID)
{
    View sectionLayout = findViewById(sectionLayoutID);
    LinearLayout settingsLayout = (LinearLayout)findViewById(R.id.appwidget_settings_layout);
    if (sectionLayout != null && settingsLayout != null)
    {
        settingsLayout.removeView(sectionLayout);
        settingsLayout.addView(sectionLayout, 0);
    }
}
 
Example 13
Source File: InfoBarControlLayout.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Adds an icon with a descriptive message to the layout.
 *
 * -----------------------------------------------------
 * | ICON | PRIMARY MESSAGE SECONDARY MESSAGE          |
 * -----------------------------------------------------
 * If an icon is not provided, the ImageView that would normally show it is hidden.
 *
 * @param iconResourceId   ID of the drawable to use for the icon.
 * @param iconColorId      ID of the tint color for the icon, or 0 for default.
 * @param primaryMessage   Message to display for the toggle.
 * @param secondaryMessage Additional descriptive text for the toggle.  May be null.
 */
public View addIcon(int iconResourceId, int iconColorId, CharSequence primaryMessage,
        CharSequence secondaryMessage) {
    LinearLayout layout = (LinearLayout) LayoutInflater.from(getContext()).inflate(
            R.layout.infobar_control_icon_with_description, this, false);
    addView(layout, new ControlLayoutParams());

    ImageView iconView = (ImageView) layout.findViewById(R.id.control_icon);
    iconView.setImageResource(iconResourceId);
    if (iconColorId != 0) {
        iconView.setColorFilter(ApiCompatibilityUtils.getColor(getResources(), iconColorId));
    }

    // The primary message text is always displayed.
    TextView primaryView = (TextView) layout.findViewById(R.id.control_message);
    primaryView.setText(primaryMessage);

    // The secondary message text is optional.
    TextView secondaryView =
            (TextView) layout.findViewById(R.id.control_secondary_message);
    if (secondaryMessage == null) {
        layout.removeView(secondaryView);
    } else {
        secondaryView.setText(secondaryMessage);
    }

    return layout;
}
 
Example 14
Source File: BoardView.java    From BoardView with Apache License 2.0 5 votes vote down vote up
private void switchItemFromPosition(int change,View view){
    LinearLayout parentLayout = (LinearLayout)(view.getParent());
    int columnPos = parentLayout.indexOfChild(view);
    if (columnPos + change >= 0 && columnPos + change < parentLayout.getChildCount()) {
        parentLayout.removeView(view);
        parentLayout.addView(view, columnPos + change);
        if (mDragItemStartCallback != null) {
            int newPos = parentLayout.indexOfChild(view);
            last_swap = System.currentTimeMillis();
            mLastSwap = newPos;
            int newColumnPos = ((LinearLayout) mobileView.getParent().getParent().getParent().getParent()).indexOfChild((View) (mobileView.getParent().getParent().getParent()));
            mDragItemStartCallback.changedPosition(view, originalItemPosition, originalPosition, newPos, newColumnPos);
        }
    }
}
 
Example 15
Source File: MoonRiseSetView.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
public void removeFromLayout(@NonNull LinearLayout parent)
{
    if (layout != null)
    {
        parent.removeView(layout);
        layout.setVisibility(View.GONE);
    }
}
 
Example 16
Source File: BookOnlineActivity.java    From coolreader with MIT License 4 votes vote down vote up
public void handleMessage(Message msg) {
    if (msg.what == 1) {
        String url = (String) msg.obj;
        int length = msg.arg1;
        ProgressBar bar = ProgressBars.get(url);
        if (bar != null) {
            // 设置进度条按读取的length长度更新
            bar.incrementProgressBy(length);
            if (bar.getProgress() == bar.getMax()) {
                notificationManager.cancel(notificationId);
                btnDownload.setText("下载");
                // 下载完成后清除进度条并将map中的数据清空
                LinearLayout layout = (LinearLayout) bar.getParent();
                layout.removeView(bar);
                ProgressBars.remove(url);
                downloaders.get(url).delete(url);
                downloaders.get(url).reset();
                downloaders.remove(url);
                
                new AlertDialog.Builder(BookOnlineActivity.this).setTitle("提示").setMessage("下载完成,是否将《"+bookNames[currentPosition]+"》加入书架?")
                .setPositiveButton("加入", new DialogInterface.OnClickListener()
                {
                    
                    public void onClick(DialogInterface dialog, int which)
                    {
                        if(BookUtil.isExist( DbDataOperation.getBookInfo(resolver), SD_PATH+bookNames[currentPosition]+".txt")==true)
                        {
                            new AlertDialog.Builder(BookOnlineActivity.this).setTitle("提示").setMessage("此书在书架中已存在,无需继续添加!").setPositiveButton("确定", null).show();
                        }
                        else
                        {
                            DbDataOperation.insertToBookInfo(resolver, bookNames[currentPosition], "未知", SD_PATH+bookNames[currentPosition]+".txt", TimeUtil.getCurrentTime(),
                                    TimeUtil.getCurrentTime(), 0, "未分类",BookUtil.getBookSize(SD_PATH+bookNames[currentPosition]+".txt"), "0.0%");
                            MainTabActivity.thMain.setCurrentTabByTag(MainTabActivity.TAB_BOOKSHELF);
                            }
                    }
                }).setNegativeButton("取消", null).show();
            }
        }
    }
}
 
Example 17
Source File: Clock.java    From always-on-amoled with GNU General Public License v3.0 4 votes vote down vote up
public void setStyle(Context context, int clockStyle, float textSize, int textColor, boolean showAmPm, Typeface font) {
    LinearLayout clockWrapper = (LinearLayout) findViewById(R.id.clock_wrapper);
    analogClock = (CustomAnalogClock) clockWrapper.findViewById(R.id.custom_analog_clock);
    ViewGroup.LayoutParams lp = clockWrapper.findViewById(R.id.custom_analog_clock).getLayoutParams();
    float clockSize = textSize < 80 ? textSize : 80;
    lp.height = (int) (clockSize * 10);
    lp.width = (int) (clockSize * 9.5);
    switch (clockStyle) {
        case DISABLED:
            removeView(clockWrapper);
            break;
        case DIGITAL_CLOCK:
            textClock = (KillableTextClock) clockWrapper.findViewById(R.id.digital_clock);
            textClock.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
            textClock.setTextColor(textColor);
            if (!showAmPm)
                textClock.setFormat12Hour("h:mm");
            if (Utils.isAndroidNewerThanN()) {
                textClock.setTextLocale(context.getResources().getConfiguration().getLocales().get(0));
            } else {
                textClock.setTextLocale(context.getResources().getConfiguration().locale);
            }
            textClock.setTypeface(font);

            clockWrapper.removeView(clockWrapper.findViewById(R.id.custom_analog_clock));
            clockWrapper.removeView(clockWrapper.findViewById(R.id.s7_digital));
            break;
        case ANALOG_CLOCK:
            clockWrapper.removeView(clockWrapper.findViewById(R.id.digital_clock));
            clockWrapper.removeView(clockWrapper.findViewById(R.id.s7_digital));
            clockWrapper.findViewById(R.id.custom_analog_clock).setLayoutParams(lp);
            analogClock.init(context, R.drawable.default_face, R.drawable.default_hour_hand, R.drawable.default_minute_hand, 225, false, false);
            break;
        case ANALOG24_CLOCK:
            clockWrapper.removeView(clockWrapper.findViewById(R.id.digital_clock));
            clockWrapper.removeView(clockWrapper.findViewById(R.id.s7_digital));
            clockWrapper.findViewById(R.id.custom_analog_clock).setLayoutParams(lp);
            analogClock.init(context, R.drawable.clock_face, R.drawable.hour_hand, R.drawable.minute_hand, 0, true, false);
            break;
        case S7_CLOCK:
            clockWrapper.removeView(clockWrapper.findViewById(R.id.digital_clock));
            clockWrapper.removeView(clockWrapper.findViewById(R.id.s7_digital));
            clockWrapper.findViewById(R.id.custom_analog_clock).setLayoutParams(lp);
            analogClock.init(context, R.drawable.s7_face, R.drawable.s7_hour_hand, R.drawable.s7_minute_hand, 0, false, false);
            break;
        case PEBBLE_CLOCK:
            clockWrapper.removeView(clockWrapper.findViewById(R.id.digital_clock));
            clockWrapper.removeView(clockWrapper.findViewById(R.id.s7_digital));
            clockWrapper.findViewById(R.id.custom_analog_clock).setLayoutParams(lp);
            analogClock.init(context, R.drawable.pebble_face, R.drawable.pebble_hour_hand, R.drawable.pebble_minute_hand, 225, false, true);
            break;
        case S7_DIGITAL:
            clockWrapper.removeView(clockWrapper.findViewById(R.id.digital_clock));
            clockWrapper.removeView(clockWrapper.findViewById(R.id.custom_analog_clock));
            if (textSize > 90)
                textSize = 90;
            Prefs prefs = new Prefs(context);
            prefs.apply();
            if (textSize < 50 && prefs.batteryStyle == 1)
                textSize = 50;
            digitalS7 = (DigitalS7) findViewById(R.id.s7_digital);
            digitalS7.init(font, textSize, textColor);
            break;
        case FLAT_CLOCK:
            clockWrapper.removeView(clockWrapper.findViewById(R.id.digital_clock));
            clockWrapper.removeView(clockWrapper.findViewById(R.id.s7_digital));
            clockWrapper.findViewById(R.id.custom_analog_clock).setLayoutParams(lp);
            analogClock.init(context, R.drawable.flat_face, R.drawable.flat_hour_hand, R.drawable.flat_minute_hand, 235, false, false);
            break;
        case FLAT_RED_CLOCK:
            clockWrapper.removeView(clockWrapper.findViewById(R.id.digital_clock));
            clockWrapper.removeView(clockWrapper.findViewById(R.id.s7_digital));
            clockWrapper.findViewById(R.id.custom_analog_clock).setLayoutParams(lp);
            analogClock.init(context, R.drawable.flat_face, R.drawable.flat_red_hour_hand, R.drawable.flat_red_minute_hand, 0, false, false);
            break;
        case FLAT_STANDARD_TICKS:
            clockWrapper.removeView(clockWrapper.findViewById(R.id.digital_clock));
            clockWrapper.removeView(clockWrapper.findViewById(R.id.s7_digital));
            clockWrapper.findViewById(R.id.custom_analog_clock).setLayoutParams(lp);
            analogClock.init(context, R.drawable.standard_ticks_face, R.drawable.hour_hand, R.drawable.minute_hand, 0, false, false);
            break;
    }
}
 
Example 18
Source File: TwoFieldDatePicker.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Reorder the date picker spinners to match the order suggested by the locale.
 * Assumes that the order of month and year in the locale is also the right order
 * for the spinner columns.
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private void reorderSpinners() {
    boolean posInserted = false;
    boolean yearInserted = false;

    LinearLayout pickers = (LinearLayout) findViewById(R.id.pickers);

    pickers.removeView(mPositionInYearSpinner);
    pickers.removeView(mYearSpinner);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        // logic duplicated from android.widget.DatePicker
        String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), "yyyyMMMdd");

        for (int i = 0; i < pattern.length(); ++i) {
            char ch = pattern.charAt(i);
            if (ch == '\'') {
                i = pattern.indexOf('\'', i + 1);
                if (i == -1) {
                    throw new IllegalArgumentException("Bad quoting in " + pattern);
                }
            } else if ((ch == 'M' || ch == 'L') && !posInserted) {
                pickers.addView(mPositionInYearSpinner);
                posInserted = true;
            } else if (ch == 'y' && !yearInserted) {
                pickers.addView(mYearSpinner);
                yearInserted = true;
            }
        }
    } else {
        // This method was used to order android.widget.DatePicker
        // fields in JB prior to the availability of
        // getBestDateTimePattern.
        char[] order = DateFormat.getDateFormatOrder(getContext());
        for (int i = 0; i < order.length; ++i) {
            if (order[i] == 'M') {
                pickers.addView(mPositionInYearSpinner);
                posInserted = true;
            } else if (order[i] == 'y') {
                pickers.addView(mYearSpinner);
                yearInserted = true;
            }
        }
    }

    if (!posInserted) pickers.addView(mPositionInYearSpinner);
    if (!yearInserted) pickers.addView(mYearSpinner);
}
 
Example 19
Source File: MoonPhasesView.java    From SuntimesWidget with GNU General Public License v3.0 4 votes vote down vote up
public void removeFromLayout(@NonNull LinearLayout parent)
{
    if (layout != null)
        parent.removeView(layout);
}
 
Example 20
Source File: AbstractMessage.java    From iGap-Android with GNU Affero General Public License v3.0 3 votes vote down vote up
private void addLayoutTime(VH holder) {

        LinearLayout ll_containerTime = (LinearLayout) holder.itemView.findViewById(R.id.contentContainer).getParent();

        if (holder.itemView.findViewById(R.id.csl_ll_time) != null) {
            ll_containerTime.removeView(holder.itemView.findViewById(R.id.csl_ll_time));
        }

        ll_containerTime.addView(ViewMaker.getViewTime(), new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    }