下面列出了android.widget.EditText#setHintTextColor ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public EditTextSettingsCell(Context context) {
super(context);
textView = new EditText(context);
textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
textView.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setLines(1);
textView.setMaxLines(1);
textView.setSingleLine(true);
textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
textView.setBackgroundDrawable(null);
textView.setPadding(0, 0, 0, 0);
textView.setInputType(textView.getInputType() |EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES);
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 0, 17, 0));
}
public EditTextSettingsCell(Context context) {
super(context);
textView = new EditText(context);
textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
textView.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setLines(1);
textView.setMaxLines(1);
textView.setSingleLine(true);
textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
textView.setBackgroundDrawable(null);
textView.setPadding(0, 0, 0, 0);
textView.setInputType(textView.getInputType() |EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES);
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 0, 17, 0));
}
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);
}
});
}
/**
* 添加生成文本输入框
* @param hint 内容
* @param paddingTop 到顶部高度
* @return
*/
private EditText createEditText(String hint, int paddingTop) {
EditText editText = new DeletableEditText(getContext());
LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
editText.setLayoutParams(layoutParams);
editText.setTextSize(16);
editText.setTextColor(Color.parseColor("#616161"));
editText.setCursorVisible(true);
editText.setBackground(null);
editText.setOnKeyListener(keyListener);
editText.setOnFocusChangeListener(focusListener);
editText.addTextChangedListener(textWatcher);
editText.setTag(viewTagIndex++);
editText.setPadding(editNormalPadding, paddingTop, editNormalPadding, paddingTop);
editText.setHint(hint);
editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, rtTextSize);
editText.setTextColor(rtTextColor);
editText.setHintTextColor(rtHintTextColor);
editText.setLineSpacing(rtTextLineSpace, 1.0f);
HyperLibUtils.setCursorDrawableColor(editText, cursorColor);
return editText;
}
protected void AdjustAddDialogColors(View layout) {
// Only for Android LOWER than 3.0 !
// Hack for lower Android versions to make text visible
// Dialog background is DIFFERENT in Android 2.1 and Android 2.3
// That's why we use gray color everywhere for Android < 3.0
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
TextView tv1 = (TextView) layout.findViewById(R.id.textView1);
TextView tv2 = (TextView) layout.findViewById(R.id.textView2);
TextView tv3 = (TextView) layout.findViewById(R.id.textView3);
EditText et1 = (EditText) layout.findViewById(R.id.point_name);
EditText et2 = (EditText) layout.findViewById(R.id.point_la);
EditText et3 = (EditText) layout.findViewById(R.id.point_lo);
tv1.setTextColor(Color.parseColor("#9E9E9E"));
tv2.setTextColor(Color.parseColor("#9E9E9E"));
tv3.setTextColor(Color.parseColor("#9E9E9E"));
et1.setTextColor(Color.parseColor("#9E9E9E"));
et2.setTextColor(Color.parseColor("#9E9E9E"));
et3.setTextColor(Color.parseColor("#9E9E9E"));
et1.setHintTextColor(Color.parseColor("#9E9E9E"));
et2.setHintTextColor(Color.parseColor("#9E9E9E"));
et3.setHintTextColor(Color.parseColor("#9E9E9E"));
}
}
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(ColorUtil.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();
}
}
/**
* Sets the edittext's hint icon and text.
*
* @param editText
* @param drawableResource
* @param hintText
*/
public static void setSearchHintIcon(EditText editText, int drawableResource, String hintText) {
try {
SpannableStringBuilder stopHint = new SpannableStringBuilder(" ");
stopHint.append(hintText);
// Add the icon as an spannable
Drawable searchIcon = editText.getContext().getResources().getDrawable(drawableResource);
Float rawTextSize = editText.getTextSize();
int textSize = (int) (rawTextSize * 1.25);
searchIcon.setBounds(0, 0, textSize, textSize);
stopHint.setSpan(new ImageSpan(searchIcon), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
// Set the new hint text
editText.setHint(stopHint);
//searchBox.setTextColor(Color.WHITE);
editText.setHintTextColor(Color.LTGRAY);
} catch (Exception e) {
Log.e("EditTextUtil", e.getMessage(), e);
}
}
/**
* Creates a new instance of {@link EditText} that is configured to specify the given content
* MIME types to EditorInfo#contentMimeTypes so that developers can locally test how the current
* input method behaves for such content MIME types.
*
* @param contentMimeTypes A {@link String} array that indicates the supported content MIME
* types
* @return a new instance of {@link EditText}, which specifies EditorInfo#contentMimeTypes with
* the given content MIME types
*/
private EditText createEditTextWithContentMimeTypes(String[] contentMimeTypes) {
final CharSequence hintText;
final String[] mimeTypes; // our own copy of contentMimeTypes.
if (contentMimeTypes == null || contentMimeTypes.length == 0) {
hintText = "MIME: []";
mimeTypes = new String[0];
} else {
hintText = "MIME: " + Arrays.toString(contentMimeTypes);
mimeTypes = Arrays.copyOf(contentMimeTypes, contentMimeTypes.length);
}
EditText exitText = new EditText(this) {
@Override
public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
final InputConnection ic = super.onCreateInputConnection(editorInfo);
EditorInfoCompat.setContentMimeTypes(editorInfo, mimeTypes);
final InputConnectionCompat.OnCommitContentListener callback =
new InputConnectionCompat.OnCommitContentListener() {
@Override
public boolean onCommitContent(InputContentInfoCompat inputContentInfo,
int flags, Bundle opts) {
return MainActivity.this.onCommitContent(
inputContentInfo, flags, opts, mimeTypes);
}
};
return InputConnectionCompat.createWrapper(ic, editorInfo, callback);
}
};
exitText.setHint(hintText);
exitText.setTextColor(Color.WHITE);
exitText.setHintTextColor(Color.WHITE);
return exitText;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.clear();
getMenuInflater().inflate(R.menu.tokens_picker_menu_main, menu);
//super.onCreateOptionsMenu(menu, getMenuInflater());
MenuItem myActionMenuItem = menu.findItem(R.id.action_search);
final SearchView searchView = (SearchView) myActionMenuItem.getActionView();
EditText searchEditText = searchView.findViewById(R.id.search_src_text);
searchEditText.setTextColor(getResources().getColor(R.color.whiteColor));
searchEditText.setHintTextColor(getResources().getColor(R.color.whiteColor));
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
if (TextUtils.isEmpty(newText)) {
simpleSearchAdapter.filter("");
} else {
simpleSearchAdapter.filter(newText);
}
return true;
}
});
return true;
}
@Override
public void showEmptyTaskError() {
Snackbar snackbar = Snackbar.make(contentView, getString(R.string.empty_task_message), Snackbar.LENGTH_SHORT);
snackbar.show();
EditText title = getActivity().findViewById(R.id.add_task_title);
title.setError(getResources().getString(R.string.add_task_empty_title));
title.setHintTextColor(Color.RED);
}
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();
}
protected void AdjustPropDialogColors(View layout) {
// Only for Android LOWER than 3.0 !
// Hack for lower Android versions to make text visible
// Dialog background is DIFFERENT in Android 2.1 and Android 2.3
// That's why we use gray color everywhere for Android < 3.0
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
EditText et1 = (EditText) layout.findViewById(R.id.mycoords_name);
et1.setTextColor(Color.parseColor("#9E9E9E"));
et1.setHintTextColor(Color.parseColor("#9E9E9E"));
}
}
private void bindViews(View view) {
addStoreButton = view.findViewById(R.id.button_dialog_add_store);
topStoresButton = view.findViewById(R.id.button_top_stores);
searchView = view.findViewById(R.id.store_search_view);
searchViewLayout = view.findViewById(R.id.search_box_layout);
errorMessage = view.findViewById(R.id.error_message);
EditText searchEditText = searchView.findViewById(androidx.appcompat.R.id.search_src_text);
searchEditText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
searchEditText.setHintTextColor(getResources().getColor(R.color.grey));
}
/**
* Creates a new instance of {@link EditText} that is configured to specify the given content
* MIME types to EditorInfo#contentMimeTypes so that developers can locally test how the current
* input method behaves for such content MIME types.
*
* @param contentMimeTypes A {@link String} array that indicates the supported content MIME
* types
* @return a new instance of {@link EditText}, which specifies EditorInfo#contentMimeTypes with
* the given content MIME types
*/
private EditText createEditTextWithContentMimeTypes(String[] contentMimeTypes) {
final CharSequence hintText;
final String[] mimeTypes; // our own copy of contentMimeTypes.
if (contentMimeTypes == null || contentMimeTypes.length == 0) {
hintText = "MIME: []";
mimeTypes = new String[0];
} else {
hintText = "MIME: " + Arrays.toString(contentMimeTypes);
mimeTypes = Arrays.copyOf(contentMimeTypes, contentMimeTypes.length);
}
EditText exitText = new EditText(this) {
@Override
public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
final InputConnection ic = super.onCreateInputConnection(editorInfo);
EditorInfoCompat.setContentMimeTypes(editorInfo, mimeTypes);
final InputConnectionCompat.OnCommitContentListener callback =
new InputConnectionCompat.OnCommitContentListener() {
@Override
public boolean onCommitContent(InputContentInfoCompat inputContentInfo,
int flags, Bundle opts) {
return MainActivity.this.onCommitContent(
inputContentInfo, flags, opts, mimeTypes);
}
};
return InputConnectionCompat.createWrapper(ic, editorInfo, callback);
}
};
exitText.setHint(hintText);
exitText.setTextColor(Color.WHITE);
exitText.setHintTextColor(Color.WHITE);
return exitText;
}
@SuppressLint("NewApi")
public SearchBar(Context context, AttributeSet attrs) {
super(context, attrs);
// 方式1获取属性
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.SearchBar);
hintString = a.getString(R.styleable.SearchBar_searchbar_hint);
etBackground = a
.getDrawable(R.styleable.SearchBar_searchbar_edittext_background);
searchbarLogo = a.getDrawable(R.styleable.SearchBar_searchbar_logo);
searchbarIcon = a.getDrawable(R.styleable.SearchBar_searchbar_icon);
searchbarDeleteIcon = a
.getDrawable(R.styleable.SearchBar_searchbar_delete_icon);
hintTextColor = a.getColor(
R.styleable.SearchBar_searchbar_hint_text_color, getResources()
.getColor(R.color.gray));
etTextColor = a.getColor(
R.styleable.SearchBar_searchbar_edittext_text_color,
getResources().getColor(R.color.gray));
etTextSize = a.getDimension(
R.styleable.SearchBar_searchbar_edittext_text_size, -1);
a.recycle();
View view = LayoutInflater.from(context).inflate(R.layout.search_bar,
null);
rlEditText = (RelativeLayout) view.findViewById(R.id.rlEditText);
if (etBackground != null)
rlEditText.setBackground(etBackground);
ivSearchBarLogo = (ImageView) view.findViewById(R.id.ivSearchBarLogo);
if (searchbarLogo != null)
ivSearchBarLogo.setImageDrawable(searchbarLogo);
else
ivSearchBarLogo.setVisibility(View.GONE);
ivSearchBarIcon = (ImageView) view.findViewById(R.id.ivSearchBarIcon);
if (ivSearchBarIcon != null)
ivSearchBarIcon.setImageDrawable(searchbarIcon);
ivSearchbarDeleteIcon = (ImageView) view
.findViewById(R.id.iv_searchbar_delete);
if (ivSearchbarDeleteIcon != null)
ivSearchbarDeleteIcon.setImageDrawable(searchbarDeleteIcon);
etSearch = (EditText) view.findViewById(R.id.et_searchbar);
etSearch.setTextColor(etTextColor);
if (etTextSize != -1)
etSearch.setTextSize(DensityUtils.px2dip(context, etTextSize));
etSearch.setHintTextColor(hintTextColor);
if (hintString != null)
etSearch.setHint(hintString);
else
etSearch.setHint("");
ivSearchbarDeleteIcon.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
etSearch.setText("");
}
});
// 给编辑框添加文本改变事件
etSearch.addTextChangedListener(new SearchBarTextWatcher(this));
// 把获得的view加载到这个控件中
addView(view);
}
public PasswordEditText(Context context, AttributeSet attrs) {
super(context, attrs);
// 方式1获取属性
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.PasswordEditText);
hintString = a
.getString(R.styleable.PasswordEditText_PasswordEditText_hint);
passwordEditTextToggle = a
.getDrawable(R.styleable.PasswordEditText_PasswordEditText_toggle);
hintColor = a.getColor(R.styleable.PasswordEditText_PasswordEditText_hint_color,getContext().getResources().getColor(R.color.gray_half_5));
passwordEditTextIcon = a
.getDrawable(R.styleable.PasswordEditText_PasswordEditText_icon);
passwordEditTextBackground = a
.getDrawable(R.styleable.PasswordEditText_PasswordEditText_background);
a.recycle();
View view = LayoutInflater.from(context).inflate(
R.layout.password_edittext, null);
tbPasswordEditTextToggle = (ToggleButton) view
.findViewById(R.id.tb_password_eidttext_toggle);
if (passwordEditTextToggle != null)
tbPasswordEditTextToggle
.setBackgroundDrawable(passwordEditTextToggle);
et = (EditText) view.findViewById(R.id.et_password_eidttext_edittext);
if (!TextUtils.isEmpty(hintString))
et.setHint(hintString);
et.setHintTextColor(hintColor);
rl = (RelativeLayout) view
.findViewById(R.id.rl);
if(passwordEditTextBackground !=null)
rl.setBackgroundDrawable(passwordEditTextBackground);
ivPasswordEditTextIcon = (ImageView) view.findViewById(R.id.iv_with_del_eidttext_icon);
if (passwordEditTextIcon != null)
ivPasswordEditTextIcon
.setImageDrawable(passwordEditTextIcon);
tbPasswordEditTextToggle.setChecked(true);
tbPasswordEditTextToggle
.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (!isChecked) {
et.setTransformationMethod(HideReturnsTransformationMethod
.getInstance());
} else {
et.setTransformationMethod(PasswordTransformationMethod
.getInstance());
}
et.postInvalidate();
Editable editable = et.getText();
et.setSelection(editable.length());
}
});
// ivPasswordEditTextToggle.setOnClickListener(new OnClickListener() {
// @Override
// public void onClick(View v) {
//
// if (tbPasswordEditTextToggle.isChecked()) {
// et.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
// } else {
// et.setInputType(InputType.TYPE_TEXT_VARIATION_NORMAL);
// }
// }
// });
// 给编辑框添加文本改变事件
// et.addTextChangedListener(new MyTextWatcher());
// 把获得的view加载到这个控件中
addView(view);
}
public WithDelEditText(Context context, AttributeSet attrs) {
super(context, attrs);
// 方式1获取属性
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.WithDelEditText);
hintString = a
.getString(R.styleable.WithDelEditText_WithDelEditText_hint);
hintColor = a.getColor(R.styleable.WithDelEditText_WithDelEditText_hint_color, getContext().getResources().getColor(R.color.gray_half_5));
WithDelEditTextIcon = a
.getDrawable(R.styleable.WithDelEditText_WithDelEditText_icon);
WithDelEditTextDeleteIcon = a
.getDrawable(R.styleable.WithDelEditText_WithDelEditText_delete_icon);
WithDelEditTextDeleteIcon = a
.getDrawable(R.styleable.WithDelEditText_WithDelEditText_delete_icon);
WithDelEditTextBackground = a
.getDrawable(R.styleable.WithDelEditText_WithDelEditText_background);
lines = a.getInteger(R.styleable.WithDelEditText_WithDelEditText_lines, 1);
maxLines = a.getInteger(R.styleable.WithDelEditText_WithDelEditText_maxLines, 1);
a.recycle();
View view = LayoutInflater.from(context).inflate(
R.layout.with_del_edittext, null);
ivWithDelEditTextDeleteIcon = (ImageView) view
.findViewById(R.id.iv_with_del_eidttext_delete);
if (WithDelEditTextDeleteIcon != null)
ivWithDelEditTextDeleteIcon
.setImageDrawable(WithDelEditTextDeleteIcon);
rl = (RelativeLayout) view
.findViewById(R.id.rl);
if (WithDelEditTextBackground != null)
rl.setBackgroundDrawable(WithDelEditTextBackground);
et = (EditText) view.findViewById(R.id.et_with_del_edittext);
if (!TextUtils.isEmpty(hintString))
et.setHint(hintString);
et.setHintTextColor(hintColor);
ivWithDelEditTextIcon = (ImageView) view.findViewById(R.id.iv_with_del_eidttext_icon);
if (WithDelEditTextIcon != null) {
ivWithDelEditTextIcon
.setImageDrawable(WithDelEditTextIcon);
ivWithDelEditTextIcon.setVisibility(VISIBLE);
}
ivWithDelEditTextDeleteIcon.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
et.setText("");
}
});
et.setLines(lines);
et.setMaxLines(maxLines);
// 给编辑框添加文本改变事件
et.addTextChangedListener(new MyTextWatcher());
et.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View arg0, boolean arg1) {
// TODO Auto-generated method stub
// Log.v("Steel", "arg1:"+arg1+";"+et.hasFocus());
if (et.hasFocus()) {
if (focusCheckListenter != null) {
focusCheckListenter.setOnFocusValue(true);
}
} else {
if (focusCheckListenter != null) {
focusCheckListenter.setOnFocusValue(false);
}
}
}
});
// 把获得的view加载到这个控件中
addView(view);
}
private void init(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.WithItemTextView);
String name = a
.getString(R.styleable.WithItemTextView_WithItemTextView_name);
String content = a
.getString(R.styleable.WithItemTextView_WithItemTextView_content);
int color_name = a.getColor(
R.styleable.WithItemTextView_WithItemTextView_name_color,
getResources().getColor(R.color.black));
int color_content = a.getColor(
R.styleable.WithItemTextView_WithItemTextView_content_color,
getResources().getColor(R.color.gray));
int color_content_hint = a.getColor(
R.styleable.WithItemTextView_WithItemTextView_edit_hint_color,
getResources().getColor(R.color.gray));
Drawable arrow = a.getDrawable(R.styleable.WithItemTextView_WithItemTextView_content_arrow);
boolean editable = a.getBoolean(R.styleable.WithItemTextView_WithItemTextView_editable, false);
View view = LayoutInflater.from(context).inflate(
R.layout.z_layout_item, null);
ImageView iv_arrow = (ImageView) view.findViewById(R.id.iv_arrow);
iv_arrow.setImageDrawable(arrow);
mTv_name = (TextView) view.findViewById(R.id.tv_name);
mEt_content = (EditText) view.findViewById(R.id.et_content);
mTv_content = (TextView) view.findViewById(R.id.tv_content);
mTv_name.setTextColor(color_name);
mTv_content.setTextColor(color_content);
mTv_name.setText(name);
mTv_content.setText(content);
if (editable) {
mEt_content.setHint(content);
mEt_content.setTextColor(color_content);
mEt_content.setHintTextColor(color_content_hint);
mTv_content.setVisibility(View.GONE);
mEt_content.setVisibility(View.VISIBLE);
}
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
view.setLayoutParams(lp);
a.recycle();
addView(view);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.clear();
inflater.inflate(R.menu.global_search_menu, menu);
// Create a listener for search change
final MenuItem search = menu.findItem(R.id.global_search_menu_search);
final SearchView searchView = (SearchView) search.getActionView();
searchView.setIconifiedByDefault(true);
searchView.setIconified(false);
final SearchView.OnQueryTextListener queryTextListener
= new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
@Override
public boolean onQueryTextSubmit(String query) {
mSwipeRefreshLayout.setRefreshing(true);
mEmptyView.setRefreshing(true);
Message msg = Message.obtain();
msg.obj = ClementineMessageFactory.buildGlobalSearch(query);
App.ClementineConnection.mHandler.sendMessage(msg);
hideSoftInput();
// Set the actionbar title
mActionBar.setTitle(getResources().getString(R.string.global_search_query, query));
mActionBar.setSubtitle("/");
// Query must be empty in order to collapse the search view.
searchView.setQuery("", false);
searchView.setIconified(true);
// Remove currently present adapters
mAdapters.clear();
showList();
return true;
}
};
searchView.setOnQueryTextListener(queryTextListener);
searchView.setQueryHint(getString(R.string.global_search_search));
EditText searchText = (EditText) searchView.findViewById(
android.support.v7.appcompat.R.id.search_src_text);
searchText.setHintTextColor(ContextCompat.getColor(getActivity(),
R.color.searchview_edittext_hint));
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
helper = new KeyboardHelper(getActivity());
View res = inflater.inflate(R.layout.fragment_create_group_name, container, false);
res.setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
TextView hintTextView = (TextView) res.findViewById(R.id.create_group_hint);
hintTextView.setTextColor(ActorSDK.sharedActor().style.getTextSecondaryColor());
if (isChannel) {
hintTextView.setText(R.string.create_channel_hint);
} else {
hintTextView.setText(R.string.create_group_hint);
}
groupName = (EditText) res.findViewById(R.id.groupTitle);
groupName.setOnEditorActionListener((v, actionId, event) -> {
if (actionId == EditorInfo.IME_ACTION_NEXT) {
next();
return true;
}
return false;
});
if (isChannel) {
groupName.setHint(R.string.create_channel_name_hint);
} else {
groupName.setHint(R.string.create_group_name_hint);
}
groupName.setTextColor(ActorSDK.sharedActor().style.getTextPrimaryColor());
groupName.setHintTextColor(ActorSDK.sharedActor().style.getTextHintColor());
avatarView = (AvatarView) res.findViewById(R.id.avatar);
avatarView.init(Screen.dp(96), 24);
avatarView.getHierarchy().setPlaceholderImage(R.drawable.circle_placeholder);
// avatarView.getHierarchy().setControllerOverlay(getResources().getDrawable(R.drawable.circle_selector));
avatarView.setImageURI(null);
res.findViewById(R.id.pickAvatar).setOnClickListener(view -> {
startActivityForResult(Intents.pickAvatar(avatarPath != null, getActivity()), REQUEST_AVATAR);
});
return res;
}