当前位置: 首页>>代码示例>>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;未经允许,请勿转载。