本文整理汇总了Java中android.support.v7.widget.AppCompatEditText类的典型用法代码示例。如果您正苦于以下问题:Java AppCompatEditText类的具体用法?Java AppCompatEditText怎么用?Java AppCompatEditText使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AppCompatEditText类属于android.support.v7.widget包,在下文中一共展示了AppCompatEditText类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.support.v7.widget.AppCompatEditText; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.status_add_new);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle("发送微博");
final AppCompatEditText editText = (AppCompatEditText) findViewById(R.id.inputText);
findViewById(R.id.send).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String status = editText.getText().toString();
new UpdateStatusAsync().execute(status);
}
});
}
示例2: init
import android.support.v7.widget.AppCompatEditText; //导入依赖的package包/类
protected void init(Context context, AttributeSet attrs) {
setOrientation(VERTICAL);
inflate(context, R.layout.layout_delete_on_swipe_edit_text, this);
editText = (AppCompatEditText) getChildAt(0);
//Threshold cannot be bigger than EditText itself
if (attrs != null) {
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.DeleteOnSwipeEditText);
setHint(ta.getString(R.styleable.DeleteOnSwipeEditText_android_hint));
int threshold = ta.getInt(R.styleable.DeleteOnSwipeEditText_hrskrs_threshold, INVALID);
if (threshold > MIN_THRESHOLD) {
DEFAULT_THRESHOLD = threshold;
}
int swipeMode = ta.getInt(R.styleable.DeleteOnSwipeEditText_hrskrs_swipe_mode, INVALID);
if (swipeMode == 1) {
DEFAULT_SWIPE = SINGLE_FINGER_SWIPE;
}
ta.recycle();
}
//EditText touch listener
editText.setOnTouchListener(this);
}
示例3: getFirstBadResultOrSuccess
import android.support.v7.widget.AppCompatEditText; //导入依赖的package包/类
public static RxVerifyCompacResult<AppCompatEditText> getFirstBadResultOrSuccess(
List<RxVerifyCompacResult<AppCompatEditText>> results) {
RxVerifyCompacResult<AppCompatEditText> firstBadResult = null;
for (RxVerifyCompacResult<AppCompatEditText> result : results) {
if (!result.isProper()) {
firstBadResult = result;
break;
}
}
if (firstBadResult == null) {
// if there is no bad result, then return first success
return results.get(0);
} else {
return firstBadResult;
}
}
示例4: onCreateView
import android.support.v7.widget.AppCompatEditText; //导入依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_buildprop_search, container, false);
AppCompatEditText keyEdit = (AppCompatEditText) rootView.findViewById(R.id.key_edittext);
AppCompatEditText valueEdit = (AppCompatEditText) rootView.findViewById(R.id.value_edittext);
keyEdit.addTextChangedListener(mKeyWatcher);
valueEdit.addTextChangedListener(mValueWatcher);
if (mKeyText != null) {
keyEdit.append(mKeyText);
}
if (mValueText != null) {
valueEdit.append(mValueText);
}
mItemsText = (TextView) rootView.findViewById(R.id.found_text);
setCount(mItemsCount);
return rootView;
}
示例5: onCreate
import android.support.v7.widget.AppCompatEditText; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_editor);
initToolBar();
String title = getIntent().getStringExtra(TITLE_INTENT);
if (title != null) {
getSupportActionBar().setTitle(title);
}
CharSequence text = getIntent().getCharSequenceExtra(TEXT_INTENT);
mEditText = (AppCompatEditText) findViewById(R.id.edittext);
if (text != null) {
mEditText.append(text);
}
}
示例6: onViewCreated
import android.support.v7.widget.AppCompatEditText; //导入依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
editGeohash = (AppCompatEditText) view.findViewById(R.id.edit_hash);
editLat = (AppCompatEditText) view.findViewById(R.id.edit_lat);
editLon = (AppCompatEditText) view.findViewById(R.id.edit_lon);
textPrecision = (AppCompatTextView) view.findViewById(R.id.text_precision);
seekPrecision = (AppCompatSeekBar) view.findViewById(R.id.seek_precision);
editGeohash.addTextChangedListener(hashTextWatcher);
editLat.addTextChangedListener(locationTextWatcher);
editLon.addTextChangedListener(locationTextWatcher);
seekPrecision.setOnSeekBarChangeListener(this);
location = new Location("geohash_example");
textPrecision.setText("Precision: " + 1);
}
示例7: getInputDialog
import android.support.v7.widget.AppCompatEditText; //导入依赖的package包/类
/**
* 获取一个输入对话框
*/
public static AlertDialog.Builder getInputDialog(
Context context,
String title,
AppCompatEditText editText,
String positiveText,
String negativeText,
boolean cancelable,
DialogInterface.OnClickListener positiveListener,
DialogInterface.OnClickListener negativeListener) {
return getDialog(context)
.setCancelable(cancelable)
.setTitle(title)
.setView(editText)
.setPositiveButton(positiveText, positiveListener)
.setNegativeButton(negativeText, negativeListener);
}
示例8: setTint
import android.support.v7.widget.AppCompatEditText; //导入依赖的package包/类
public static void setTint(@NonNull EditText editText, @ColorInt int color, boolean useDarker) {
final ColorStateList editTextColorStateList = new ColorStateList(new int[][]{
new int[]{-android.R.attr.state_enabled},
new int[]{android.R.attr.state_enabled, -android.R.attr.state_pressed, -android.R.attr.state_focused},
new int[]{}
}, new int[]{
ContextCompat.getColor(editText.getContext(), useDarker ? R.color.ate_text_disabled_dark : R.color.ate_text_disabled_light),
ContextCompat.getColor(editText.getContext(), useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light),
color
});
if (editText instanceof AppCompatEditText) {
((AppCompatEditText) editText).setSupportBackgroundTintList(editTextColorStateList);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
editText.setBackgroundTintList(editTextColorStateList);
}
setCursorTint(editText, color);
}
示例9: initView
import android.support.v7.widget.AppCompatEditText; //导入依赖的package包/类
private void initView() {
btnSave = (Button) findViewById(R.id.btnSave);
btnSave.setOnClickListener(this);
btndel = (Button) findViewById(R.id.btndel);
btndel.setOnClickListener(this);
btnupdate = (Button) findViewById(R.id.btnupdate);
btnupdate.setOnClickListener(this);
btnQuery = (Button) findViewById(R.id.btnQuery);
btnQuery.setOnClickListener(this);
tvTextView = (TextView) findViewById(R.id.tv);
tvTextView.setFocusable(true);
etFirstName = (AppCompatEditText) findViewById(R.id.etFirstName);
etFirstName.setOnClickListener(this);
btn_back = (ImageView) findViewById(R.id.btn_back);
btn_back.setOnClickListener(this);
}
示例10: showAddDialog
import android.support.v7.widget.AppCompatEditText; //导入依赖的package包/类
private void showAddDialog() {
View customView = LayoutInflater.from(this).inflate(R.layout.dialog_book_add, null);
final AppCompatEditText editText = ButterKnife.findById(customView, R.id.inputEditText);
materialDialog = new MaterialDialog.Builder(this)
.customView(customView, false)
.positiveColorRes(R.color.positive_color)
.negativeColorRes(R.color.positive_color)
.positiveText(R.string.action_sure)
.negativeText(R.string.action_cancel)
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
String name = editText.getText().toString();
addBook(name);
}
})
.build();
materialDialog.show();
}
示例11: showFilterDialog
import android.support.v7.widget.AppCompatEditText; //导入依赖的package包/类
private void showFilterDialog() {
View customView = LayoutInflater.from(this).inflate(R.layout.dialog_book_filter, null);
final AppCompatEditText editText = ButterKnife.findById(customView, R.id.inputEditText);
materialDialog = new MaterialDialog.Builder(this)
.customView(customView, false)
.positiveColorRes(R.color.positive_color)
.negativeColorRes(R.color.positive_color)
.positiveText(R.string.action_sure)
.negativeText(R.string.action_cancel)
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
String filter = editText.getText().toString();
filterBookList(filter);
}
})
.build();
materialDialog.show();
}
示例12: onCreate
import android.support.v7.widget.AppCompatEditText; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit_text_block);
ButterKnife.bind(this);
mTextBlock.setOnUpdateViewListener(new EditTextBlock.UpdateViewListener() {
@Override
public void onRemove(EditTextBlock editTextBlock) {
mLayout.removeView(editTextBlock);
}
@Override
public void onEditTextFocusChange(AppCompatEditText v, boolean hasFocus, EditTextBlock textBlock) {
Snackbar.make(mLayout,"焦点改变",Snackbar.LENGTH_SHORT).show();
}
});
}
示例13: onCreateView
import android.support.v7.widget.AppCompatEditText; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_login, container, false);
loginName = (AppCompatEditText) view.findViewById(R.id.login_name);
loginPassword = (AppCompatEditText) view.findViewById(R.id.login_password);
AppCompatButton signInButton = (AppCompatButton) view.findViewById(R.id.sign_in_button);
signInButton.setOnClickListener(__ -> {
if (isInputDataValid()) {
String name = loginName.getText().toString();
String password = loginPassword.getText().toString();
mPresenter.saveUser(name, password);
mPresenter.attemptLogin(name, password, false);
} else {
showInputDataError();
}
});
return view;
}
示例14: setTint
import android.support.v7.widget.AppCompatEditText; //导入依赖的package包/类
public static void setTint(@NonNull EditText editText, @ColorInt int color, boolean useDarker) {
final ColorStateList editTextColorStateList = new ColorStateList(new int[][]{
new int[]{-android.R.attr.state_enabled},
new int[]{android.R.attr.state_enabled, -android.R.attr.state_pressed, -android.R.attr.state_focused},
new int[]{}
}, new int[]{
ContextCompat.getColor(editText.getContext(), useDarker ? R.color.ate_disabled_edittext_dark : R.color.ate_disabled_edittext_light),
Util.resolveColor(editText.getContext(), R.attr.colorControlNormal),
color
});
if (editText instanceof AppCompatEditText) {
((AppCompatEditText) editText).setSupportBackgroundTintList(editTextColorStateList);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
editText.setBackgroundTintList(editTextColorStateList);
}
}
示例15: showEditDialog
import android.support.v7.widget.AppCompatEditText; //导入依赖的package包/类
private void showEditDialog(TodoItem item) {
View customView = LayoutInflater.from(this).inflate(R.layout.dialog_todo_edit, null);
final AppCompatEditText editText = ButterKnife.findById(customView, R.id.inputEditText);
editText.setText(item.getDescription());
editText.setSelection(item.getDescription().length());
materialDialog = new MaterialDialog.Builder(this)
.customView(customView, false)
.positiveColorRes(R.color.positive_color)
.negativeColorRes(R.color.positive_color)
.positiveText(R.string.action_sure)
.negativeText(R.string.action_cancel)
.onPositive((dialog, which) -> {
String text = editText.getText().toString();
if (!TextUtils.isEmpty(text)) {
actionCreator.createItemEditAction(item.getId(), text, item.isCompleted(), item.isStared());
dialog.dismiss();
}
})
.build();
materialDialog.show();
}