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


Java EditText.setBackgroundColor方法代碼示例

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


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

示例1: validateNumericTextInput

import android.widget.EditText; //導入方法依賴的package包/類
public static Double validateNumericTextInput(EditText edtInput, Double dDefault, Double dMin, Double dMax)    {
    String strText = edtInput.getText().toString();
    double dValue = dDefault;
    Boolean bInputRight = true;
    try {
        dValue = Double.parseDouble(strText);
    } catch (NumberFormatException e)  {
        bInputRight = false;
    }
    if (dMin != null && dValue < dMin)  {
        bInputRight = false;
    } else if (dMax != null && dValue > dMax)  {
        bInputRight = false;
    }
    if (!bInputRight)    {
    	edtInput.setBackgroundColor(ERROR_BKGRND_COLOR);
    } else  {
    	edtInput.setBackgroundColor(NORMAL_BKGRND_COLOR);
    }
    if (bInputRight)    {
        return dValue;
    } else  {
        return null;
    }
}
 
開發者ID:woshiwpa,項目名稱:SmartMath,代碼行數:26,代碼來源:ActivityConfigXYZGraph.java

示例2: validateInclusiveIntRange

import android.widget.EditText; //導入方法依賴的package包/類
public static Integer validateInclusiveIntRange(EditText edtInput, Integer nDefault, Integer nMin, Integer nMax)    {
    String strText = edtInput.getText().toString();
    int nValue = nDefault;
    Boolean bInputRight = true;
    try {
        nValue = Integer.parseInt(strText);
    } catch (NumberFormatException e)  {
        bInputRight = false;
    }
    if (nMin != null && nValue < nMin)  {
        bInputRight = false;
    } else if (nMax != null && nValue > nMax)  {
        bInputRight = false;
    }
    if (!bInputRight)    {
    	edtInput.setBackgroundColor(ERROR_BKGRND_COLOR);
    } else  {
    	edtInput.setBackgroundColor(NORMAL_BKGRND_COLOR);
    }
    if (bInputRight)    {
        return nValue;
    } else  {
        return null;
    }
}
 
開發者ID:woshiwpa,項目名稱:SmartMath,代碼行數:26,代碼來源:ActivityConfig3DExprGraph.java

示例3: validateToFromTextInput

import android.widget.EditText; //導入方法依賴的package包/類
public static Double validateToFromTextInput(EditText edtFrom, EditText edtTo, Double dDefaultFrom, Double dDefaultTo, boolean bReturnFrom)    {
    String strFrom = edtFrom.getText().toString();
    String strTo = edtTo.getText().toString();
    double dValueFrom = dDefaultFrom, dValueTo = dDefaultTo;
    Boolean bInputRight = true;
    try {
        dValueFrom = Double.parseDouble(strFrom);
        dValueTo = Double.parseDouble(strTo);
    } catch (NumberFormatException e)  {
        bInputRight = false;
    }
    if (bInputRight && dValueFrom >= dValueTo)  {
        bInputRight = false;
    }
    if (!bInputRight)    {
    	edtFrom.setBackgroundColor(ERROR_BKGRND_COLOR);
    	edtTo.setBackgroundColor(ERROR_BKGRND_COLOR);
    } else  {
    	edtFrom.setBackgroundColor(NORMAL_BKGRND_COLOR);
    	edtTo.setBackgroundColor(NORMAL_BKGRND_COLOR);
    }
    if (bInputRight)    {
        return bReturnFrom?dValueFrom:dValueTo;
    } else  {
        return null;
    }
}
 
開發者ID:woshiwpa,項目名稱:SmartMath,代碼行數:28,代碼來源:ActivityConfig3DExprGraph.java

示例4: initSearchView

import android.widget.EditText; //導入方法依賴的package包/類
private void initSearchView() {
    SearchView searchView = mBinding.svSearch;
    //設置搜索框左邊距
    LinearLayout editFrame = (LinearLayout) findViewById(R.id.search_edit_frame);
    LinearLayout.LayoutParams editP = (LayoutParams) editFrame.getLayoutParams();
    editP.leftMargin = 0;
    editP.rightMargin = 0;
    ImageView imageView = (ImageView) findViewById(R.id.search_mag_icon);
    imageView.setAdjustViewBounds(true);
    imageView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    LinearLayout.LayoutParams lp3 = (LayoutParams) imageView.getLayoutParams();
    lp3.gravity = Gravity.CENTER_VERTICAL;
    lp3.leftMargin = (int) (DensityUtil.dip2px(8f) * DensityUtil.getBaseScale(getContext()));
    lp3.rightMargin = (int) (DensityUtil.dip2px(-2f) * DensityUtil.getBaseScale(getContext()));

    View view = searchView.findViewById(R.id.search_plate);
    view.setBackgroundColor(getResources().getColor(R.color.colorTransparent));
    EditText editText = (EditText) searchView.findViewById(R.id.search_src_text);
    editText.setBackgroundColor(Color.TRANSPARENT);
    editText.setTextSize(11.5f);
    editText.setTextColor(getResources().getColor(R.color.colorText));
    editText.setHintTextColor(getResources().getColor(R.color.colorHint));
    try {
        Field fCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
        fCursorDrawableRes.setAccessible(true);
        int mCursorDrawableRes = fCursorDrawableRes.getInt(editText);
        Field fEditor = TextView.class.getDeclaredField("mEditor");
        fEditor.setAccessible(true);
        Object editor = fEditor.get(editText);
        Class<?> clazz = editor.getClass();
        Field fCursorDrawable = clazz.getDeclaredField("mCursorDrawable");
        fCursorDrawable.setAccessible(true);
        if (mCursorDrawableRes <= 0) return;
        Drawable cursorDrawable = ContextCompat.getDrawable(searchView.getContext(), mCursorDrawableRes);
        if (cursorDrawable == null) return;
        Drawable tintDrawable = DrawableCompat.wrap(cursorDrawable);
        DrawableCompat.setTintList(tintDrawable, ColorStateList.valueOf(ContextCompat.getColor(getContext(), R.color.bg_search)));
        Drawable[] drawables = new Drawable[]{tintDrawable, tintDrawable};
        fCursorDrawable.set(editor, drawables);
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
 
開發者ID:xieyangxuejun,項目名稱:SearchLayout,代碼行數:44,代碼來源:FlowSearchLayout.java

示例5: ShowError

import android.widget.EditText; //導入方法依賴的package包/類
private void ShowError(EditText edit)
{
    edit.setBackgroundColor(0xff3333);
}
 
開發者ID:toonine,項目名稱:BalaFM,代碼行數:5,代碼來源:ChangePasswordActivity.java

示例6: disableEditText

import android.widget.EditText; //導入方法依賴的package包/類
public void disableEditText(EditText editText) {
    editText.setFocusable(false);
    editText.setOnClickListener(this);
    editText.setCursorVisible(false);
    editText.setBackgroundColor(Color.TRANSPARENT);
}
 
開發者ID:odoo-mobile-intern,項目名稱:odoo-work,代碼行數:7,代碼來源:TaskDetailScroll.java


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