本文整理匯總了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);
}