當前位置: 首頁>>代碼示例>>Java>>正文


Java LinearLayout.removeViews方法代碼示例

本文整理匯總了Java中android.widget.LinearLayout.removeViews方法的典型用法代碼示例。如果您正苦於以下問題:Java LinearLayout.removeViews方法的具體用法?Java LinearLayout.removeViews怎麽用?Java LinearLayout.removeViews使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.LinearLayout的用法示例。


在下文中一共展示了LinearLayout.removeViews方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setPreviewColor

import android.widget.LinearLayout; //導入方法依賴的package包/類
private void setPreviewColor() {
	if (mView == null) return;
	ImageView iView = new ImageView(getContext());
	LinearLayout widgetFrameView = ((LinearLayout)mView.findViewById(android.R.id.widget_frame));
	if (widgetFrameView == null) return;
	widgetFrameView.setVisibility(View.VISIBLE);
	widgetFrameView.setPadding(
		widgetFrameView.getPaddingLeft(),
		widgetFrameView.getPaddingTop(),
		(int)(mDensity * 8),
		widgetFrameView.getPaddingBottom()
	);
	// remove already create preview image
	int count = widgetFrameView.getChildCount();
	if (count > 0) {
		widgetFrameView.removeViews(0, count);
	}
	widgetFrameView.addView(iView);
	widgetFrameView.setMinimumWidth(0);
	iView.setBackgroundDrawable(new AlphaPatternDrawable((int)(5 * mDensity)));
	iView.setImageBitmap(getPreviewBitmap());
}
 
開發者ID:Bregnet,項目名稱:TextView_CustomEdit_CustomColor,代碼行數:23,代碼來源:ColorPickerPreference.java

示例2: setPreviewColor

import android.widget.LinearLayout; //導入方法依賴的package包/類
private void setPreviewColor() {
	if (mView == null) return;
	ImageView iView = new ImageView(getContext());
	LinearLayout widgetFrameView = ((LinearLayout)mView.findViewById(android.R.id.widget_frame));
	if (widgetFrameView == null) return;
	widgetFrameView.setVisibility(View.VISIBLE);
	widgetFrameView.setPadding(
		widgetFrameView.getPaddingLeft(),
		widgetFrameView.getPaddingTop(),
		(int)(mDensity * 8),
		widgetFrameView.getPaddingBottom()
	);
	// remove already create preview image
	int count = widgetFrameView.getChildCount();
	if (count > 0) {
		widgetFrameView.removeViews(0, count);
	}
	widgetFrameView.addView(iView);
	widgetFrameView.setMinimumWidth(0);
	iView.setBackground(new AlphaPatternDrawable((int)(5 * mDensity)));
	iView.setImageBitmap(getPreviewBitmap());
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:23,代碼來源:ColorPickerPreference.java

示例3: updateLayout

import android.widget.LinearLayout; //導入方法依賴的package包/類
public void updateLayout(Activity activity) {
	
	final LayoutInflater inflater = activity.getLayoutInflater();
	final ArrayList<Setting> settings = mApp.getSettings();
	final int settingCount = getSettingsCount(settings);
	final LinearLayout layout = mList;

	// Go through all settings and ensure they have corresponding 
	// views in the layout. Then remove not used views in such.
	
	for (int settingIndex = 0; settingIndex < settingCount; settingIndex++) {

		int layoutIndex = settingIndex << 1;
		View layoutView = layout.getChildCount() < layoutIndex ? null : layout.getChildAt(layoutIndex);

		Setting setting = settings.get(settingIndex + 1);
		View settingView = setting.getAssignedRenderer().getView(inflater, setting, null, activity);
		
		if (layoutView == null) {
			// we just need to append setting view

			safelyRemoveViewFromParent(layout, layoutIndex, settingView);

    		// add setting view
    		layout.addView(settingView);
    		
			// add delimiter if it is not the last setting
			ImageView delimiter = new ImageView(activity);
			delimiter.setImageResource(android.R.drawable.divider_horizontal_dim_dark);
			layout.addView(delimiter);
			settingView.setTag(delimiter);
			
		} else if (layoutView != settingView) {
			
			// we just need to remove current view and put setting view instead
			// replace view
			layout.removeView(layoutView);

    		// detach it from a parent if there is a parent
			safelyRemoveViewFromParent(layout, layoutIndex, settingView);
			
			layout.addView(settingView, layoutIndex); // add setting view
			settingView.setTag(layout.getChildAt(layoutIndex + 1)); // reuse delimiter
		} 
		// else - do nothing, this is same view
		
	}
	
	// if we have more views then settings, we have to remove redundant views
	final int layoutCount = layout.getChildCount();
	final int expectedCount = settingCount << 1;
	if (layoutCount > expectedCount) {
		layout.removeViews(expectedCount, layoutCount - expectedCount);
	}
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:56,代碼來源:ListSettingsLayout.java

示例4: deleteArgument

import android.widget.LinearLayout; //導入方法依賴的package包/類
/**
 * Procedure deletes argument layout for given term and returns the previous term
 */
protected TermField deleteArgument(TermField owner, String sep, boolean storeUndoState)
{
    // target layout where terms will be deleted
    View expandable = owner.getLayout();
    if (expandable == null)
    {
        return null;
    }
    LinearLayout expandableLayout = (LinearLayout) expandable;

    // view index of the field within the parent layout
    int startIndex = ViewUtils.getViewIndex(expandableLayout, owner.getEditText());
    if (startIndex < 0)
    {
        return null;
    }

    // how much views shall be deleted:
    int count = 1;
    {
        final String termKey = getContext().getResources().getString(R.string.formula_arg_term_key);
        final boolean firstTerm = owner.getTermKey().equals(termKey + String.valueOf(1));
        if (firstTerm && startIndex + 1 < expandableLayout.getChildCount()
                && expandableLayout.getChildAt(startIndex + 1) instanceof CustomTextView)
        {
            final CustomTextView next = ((CustomTextView) expandableLayout.getChildAt(startIndex + 1));
            if (next.getText().toString().equals(sep))
            {
                count++;
            }
        }
        else if (!firstTerm && startIndex >= 1
                && expandableLayout.getChildAt(startIndex - 1) instanceof CustomTextView)
        {
            final CustomTextView prev = ((CustomTextView) expandableLayout.getChildAt(startIndex - 1));
            if (prev.getText().toString().equals(sep))
            {
                startIndex--;
                count++;
            }
        }
    }

    if (storeUndoState && parentField != null)
    {
        getFormulaList().getUndoState().addEntry(parentField.getState());
    }
    int prevIndex = terms.indexOf(owner);
    prevIndex--;
    terms.remove(owner);
    expandableLayout.removeViews(startIndex, count);
    reIndexTerms();

    return (prevIndex >= 0) ? terms.get(prevIndex) : null;
}
 
開發者ID:mkulesh,項目名稱:microMathematics,代碼行數:59,代碼來源:FormulaTerm.java


注:本文中的android.widget.LinearLayout.removeViews方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。