本文整理汇总了Java中android.widget.EditText.setHintTextColor方法的典型用法代码示例。如果您正苦于以下问题:Java EditText.setHintTextColor方法的具体用法?Java EditText.setHintTextColor怎么用?Java EditText.setHintTextColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.EditText
的用法示例。
在下文中一共展示了EditText.setHintTextColor方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: beautyEditText
import android.widget.EditText; //导入方法依赖的package包/类
protected void beautyEditText(final EditText mEditText, String hintStr, TextWatcher mTextWatcher) {
mEditText.setHint(hintStr);
mEditText.setHintTextColor(Color.parseColor("#1e0d0d0d"));
mEditText.setTextColor(Color.parseColor("#0d0d0d"));
SDKUtils.setBackground(mEditText, this.crMgmt.getDrawable("uac_input", true));
mEditText.setTextSize(16.0f);
if (mTextWatcher != null) {
mEditText.addTextChangedListener(mTextWatcher);
}
mEditText.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mEditText.setSelection(mEditText.length());
mEditText.requestFocus();
mEditText.setFocusable(true);
}
});
}
示例2: EditTextDialogBuilder
import android.widget.EditText; //导入方法依赖的package包/类
public EditTextDialogBuilder(Context context) {
super(context);
mEditText = new EditText(mContext);
mEditText.setHintTextColor(QMUIResHelper.getAttrColor(mContext, R.attr.qmui_config_color_gray_3));
mEditText.setTextColor(QMUIResHelper.getAttrColor(mContext, R.attr.qmui_config_color_black));
mEditText.setTextSize(TypedValue.COMPLEX_UNIT_PX, QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_content_message_text_size));
mEditText.setFocusable(true);
mEditText.setFocusableInTouchMode(true);
mEditText.setImeOptions(EditorInfo.IME_ACTION_GO);
mEditText.setGravity(Gravity.CENTER_VERTICAL);
mEditText.setId(R.id.qmui_dialog_edit_input);
mRightImageView = new ImageView(mContext);
mRightImageView.setId(R.id.qmui_dialog_edit_right_icon);
mRightImageView.setVisibility(View.GONE);
}
示例3: onCreateOptionsMenu
import android.widget.EditText; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if(loaderId == DELETED_LOADER_ID){
inflater.inflate(R.menu.menu_fragment_bin, menu);
}
// Place an action bar item for searching.
MenuItem item = menu.add("Search");
item.setIcon(R.drawable.ic_search_white_24dp);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM|MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
searchView = new SearchView(myActivity);
searchView.setMaxWidth(Integer.MAX_VALUE);
// Set searchbox text to white
EditText searchEditText = (EditText) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
searchEditText.setTextColor(ContextCompat.getColor(getContext(), R.color.white));
searchEditText.setHintTextColor(ContextCompat.getColor(getContext(), R.color.white));
searchView.setOnQueryTextListener(this);
item.setActionView(searchView);
super.onCreateOptionsMenu(menu, inflater);
}
示例4: setSearchViewContentColor
import android.widget.EditText; //导入方法依赖的package包/类
public static void setSearchViewContentColor(View searchView, final @ColorInt int color) {
if (searchView == null) return;
final Class<?> cls = searchView.getClass();
try {
final Field mSearchSrcTextViewField = cls.getDeclaredField("mSearchSrcTextView");
mSearchSrcTextViewField.setAccessible(true);
final EditText mSearchSrcTextView = (EditText) mSearchSrcTextViewField.get(searchView);
mSearchSrcTextView.setTextColor(color);
mSearchSrcTextView.setHintTextColor(ATEUtil.adjustAlpha(color, 0.5f));
TintHelper.setCursorTint(mSearchSrcTextView, color);
Field field = cls.getDeclaredField("mSearchButton");
tintImageView(searchView, field, color);
field = cls.getDeclaredField("mGoButton");
tintImageView(searchView, field, color);
field = cls.getDeclaredField("mCloseButton");
tintImageView(searchView, field, color);
field = cls.getDeclaredField("mVoiceButton");
tintImageView(searchView, field, color);
} catch (Exception e) {
e.printStackTrace();
}
}
示例5: setEditViewsName
import android.widget.EditText; //导入方法依赖的package包/类
/**
* 设置编辑列表VIEW
*
* @param names 编辑view 的name
* @return this
*/
public BaseDialog setEditViewsName(List<String> names) {
if (middleLayout.getChildCount() > 0) {
middleLayout.removeAllViews();
}
for (String name :
names) {
TextView textView = new TextView(getContext());
textView.setText(name);
EditText editText = new EditText(getContext());
editText.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
editText.setHint("请输入" + name);
editText.setPadding(10, 0, 0, 0);
editText.setHintTextColor(Color.BLUE);
LinearLayout child = new LinearLayout(getContext());
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
child.setOrientation(LinearLayout.HORIZONTAL);
child.setGravity(Gravity.CENTER_VERTICAL);
child.setLayoutParams(params);
child.addView(textView);
child.addView(editText);
middleLayout.addView(child);
}
return this;
}
示例6: process
import android.widget.EditText; //导入方法依赖的package包/类
@Override
public void process(@NonNull Context context, @Nullable String key, @Nullable View target, @Nullable Integer tintColor) {
if (target == null)
return;
if (tintColor == null) {
// TODO pass a toolbar here?
final int toolbarColor = Config.toolbarColor(context, key, null);
tintColor = Config.getToolbarTitleColor(context, null, key, toolbarColor);
}
final Class<?> cls = target.getClass();
try {
final Field mSearchSrcTextViewField = cls.getDeclaredField("mSearchSrcTextView");
mSearchSrcTextViewField.setAccessible(true);
final EditText mSearchSrcTextView = (EditText) mSearchSrcTextViewField.get(target);
mSearchSrcTextView.setTextColor(tintColor);
mSearchSrcTextView.setHintTextColor(ContextCompat.getColor(context, ATEUtil.isColorLight(tintColor) ? R.color.ate_text_disabled_dark : R.color.ate_text_disabled_light));
TintHelper.setCursorTint(mSearchSrcTextView, tintColor);
Field field = cls.getDeclaredField("mSearchButton");
tintImageView(target, field, tintColor);
field = cls.getDeclaredField("mGoButton");
tintImageView(target, field, tintColor);
field = cls.getDeclaredField("mCloseButton");
tintImageView(target, field, tintColor);
field = cls.getDeclaredField("mVoiceButton");
tintImageView(target, field, tintColor);
} catch (Exception e) {
e.printStackTrace();
}
}
示例7: showInputedError
import android.widget.EditText; //导入方法依赖的package包/类
/**字符不合法提示(et == null ? toast : hint)
* @param context
* @param et
* @param string
* @return
*/
public static boolean showInputedError(Activity context, EditText et, String string) {
if (context == null || StringUtil.isNotEmpty(string, false) == false) {
Log.e(TAG, "showInputedError context == null || et == null || StringUtil.isNotEmpty(string, false) == false >> return false;");
return false;
}
if (et == null) {
Toast.makeText(context, StringUtil.getTrimedString(string), Toast.LENGTH_SHORT).show();
} else {
et.setText("");
et.setHint(string);
et.setHintTextColor(context.getResources().getColor(R.color.red));
}
return false;
}
示例8: isPhone
import android.widget.EditText; //导入方法依赖的package包/类
/**
* 手机号码
*
* @param Color
* @param edt
* @param errMsg
* @return boolean 返回类型
*/
public static boolean isPhone(int Color, EditText edt, String errMsg) {
boolean b = true;
if (!isMobileNO(edt.getText().toString())) {
if (isEmpty(errMsg))
errMsg = "手机号有误";
edt.setHint(errMsg);
edt.setHintTextColor(Color);
b = false;
}
return b;
}
示例9: init
import android.widget.EditText; //导入方法依赖的package包/类
private void init(AttributeSet attrs, int defStyle) {
// Load attributes
final TypedArray a = getContext().obtainStyledAttributes(
attrs, R.styleable.lingju, defStyle, 0);
LayoutInflater.from(getContext()).inflate(R.layout.search_online_box, this);
mLlRoot = findViewById(R.id.ll_root);
edit = (EditText) findViewById(R.id.sob_search_edit);
stateBt = (ImageButton) findViewById(R.id.sob_state_bt);
animate = AnimationUtils.loadAnimation(getContext(), R.anim.start_up_loading);
animate.setInterpolator(new LinearInterpolator());
drawable = (LevelListDrawable) stateBt.getDrawable();
edit.addTextChangedListener(searhWatcher);
edit.setOnEditorActionListener(editorActionListener);
edit.setOnClickListener(editorClickListener);
stateBt.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (stateBt.getVisibility() == View.VISIBLE && drawable.getLevel() == 1) {
edit.setText("");
stateBt.setVisibility(View.INVISIBLE);
}
}
});
edit.setHint(a.getString(R.styleable.lingju_hint));
// edit.setHintTextColor(getResources().getColor(R.color.navi_search_box_color));
edit.setHintTextColor(a.getColor(R.styleable.lingju_hintColor, getResources().getColor(R.color.navi_search_box_color)));
edit.setTextColor(a.getColor(R.styleable.lingju_textColor, getResources().getColor(R.color.ksw_md_solid_disable)));
mLlRoot.setBackgroundColor(a.getColor(R.styleable.lingju_search_background, getResources().getColor(R.color.green_style)));
//edit.setTextSize(a.getFloat(com.android.internal.R.styleable.TextView_textSize,12));
a.recycle();
}
示例10: init
import android.widget.EditText; //导入方法依赖的package包/类
private void init(Context context) {
setClipToPadding(false);
FrameLayout.LayoutParams linearLayoutParams = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
linearLayoutParams.gravity = Gravity.CENTER;
FrameLayout.LayoutParams editTextLayoutParams = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
editTextLayoutParams.gravity = Gravity.CENTER;
animatedPlaceholder = new LinearLayout(context);
animatedPlaceholder.setVisibility(INVISIBLE);
animatedPlaceholder.setOrientation(LinearLayout.HORIZONTAL);
animatedPlaceholder.setClipToPadding(false);
animatedPlaceholder.setPadding(0, 20, 0, 0);
actualEditText = new EditText(context);
actualEditText.setBackground(null);
actualEditText.setGravity(Gravity.CENTER);
actualEditText.setIncludeFontPadding(false);
actualEditText.setVisibility(INVISIBLE);
actualEditText.setPadding(0, 20, 0, 0);
if (!TextUtils.isEmpty(text)) actualEditText.setText(text);
if (!TextUtils.isEmpty(hint)) actualEditText.setHint(hint);
if (textColor != -1) actualEditText.setTextColor(textColor);
if (hintColor != -1) actualEditText.setHintTextColor(hintColor);
if (textSize != -1) actualEditText.setTextSize(textSize);
addView(animatedPlaceholder, linearLayoutParams);
addView(actualEditText, editTextLayoutParams);
if (autoStart) startAnimation();
}
示例11: 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();
}
}
示例12: isInputedCorrect
import android.widget.EditText; //导入方法依赖的package包/类
/**判断edittext输入文字是否合法
* @param context
* @param et
* @param type
* @return
*/
public static boolean isInputedCorrect(Activity context, EditText et, int type, String errorRemind) {
if (context == null || et == null) {
Log.e(TAG, "isInputedCorrect context == null || et == null >> return false;");
return false;
}
oringinalHintColor = et.getHintTextColors();
String inputed = StringUtil.getTrimedString(et);
switch (type) {
case TYPE_VERIFY:
if (type == TYPE_VERIFY && inputed.length() < 4) {
return showInputedError(context, et, StringUtil.isNotEmpty(errorRemind, true) ? errorRemind : "验证码不能小于4位");
}
break;
case TYPE_PASSWORD:
if (inputed.length() < 6) {
return showInputedError(context, et, StringUtil.isNotEmpty(errorRemind, true) ? errorRemind : "密码不能小于6位");
}
if (StringUtil.isNumberOrAlpha(inputed) == false) {
return showInputedError(context, et, StringUtil.isNotEmpty(errorRemind, true) ? errorRemind : "密码只能含有字母或数字");
}
break;
case TYPE_PHONE:
if (inputed.length() != 11) {
return showInputedError(context, et, StringUtil.isNotEmpty(errorRemind, true) ? errorRemind : "请输入11位手机号");
}
if (StringUtil.isPhone(inputed) == false) {
Toast.makeText(context, "您输入的手机号格式不对哦~", Toast.LENGTH_SHORT).show();
return false;
}
break;
case TYPE_MAIL:
if (StringUtil.isEmail(inputed) == false) {
return showInputedError(context, "您输入的邮箱格式不对哦~");
}
break;
default:
if (StringUtil.isNotEmpty(inputed, true) == false || inputed.equals(StringUtil.getTrimedString(et.getHint()))) {
return showInputedError(context, et, StringUtil.isNotEmpty(errorRemind, true) ? errorRemind : StringUtil.getTrimedString(et));
}
break;
}
et.setHintTextColor(oringinalHintColor);
return true;
}
示例13: setHintTextColor
import android.widget.EditText; //导入方法依赖的package包/类
private static void setHintTextColor(int Color, EditText edt) {
edt.setHintTextColor(Color);
}