本文整理汇总了Java中android.widget.EditText类的典型用法代码示例。如果您正苦于以下问题:Java EditText类的具体用法?Java EditText怎么用?Java EditText使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EditText类属于android.widget包,在下文中一共展示了EditText类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ChangeProductNameDialog
import android.widget.EditText; //导入依赖的package包/类
/**
* @param product Product that's being edited
* @param context Activity context
* @param onNameChanged Callback that's called after the name has been changed
*/
public ChangeProductNameDialog(final Product product, Context context, final CustomCallback onNameChanged) {
super(context,
R.layout.dialog_change_product_name,
"Set product name");
final EditText editTextName = (EditText) findViewById(R.id.editTextName);
editTextName.setText(product.getName());
setOkAction(new View.OnClickListener() {
@Override
public void onClick(View v) {
product.setName(editTextName.getText().toString());
onNameChanged.callBack();
dismiss();
}
});
}
示例2: onInput
import android.widget.EditText; //导入依赖的package包/类
@Override
public void onInput(@NonNull MaterialDialog dialog, CharSequence input) {
if (mIsFirstTextChanged) {
mIsFirstTextChanged = false;
return;
}
EditText editText = dialog.getInputEditText();
if (editText == null)
return;
int errorResId = 0;
if (input == null || input.length() == 0) {
errorResId = R.string.text_name_should_not_be_empty;
} else if (!input.equals(mExcluded)) {
if (new File(getCurrentDirectory(), mIsDirectory ? input.toString() : input.toString() + ".js").exists()) {
errorResId = R.string.text_file_exists;
}
}
if (errorResId == 0) {
editText.setError(null);
dialog.getActionButton(DialogAction.POSITIVE).setEnabled(true);
} else {
editText.setError(getString(errorResId));
dialog.getActionButton(DialogAction.POSITIVE).setEnabled(false);
}
}
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:27,代码来源:MyScriptListFragment.java
示例3: decideSoftKeyboard
import android.widget.EditText; //导入依赖的package包/类
private void decideSoftKeyboard() {
View hostView;
if ((hostView = getHostView()) != null) {
final Context context = getContext();
if (context != null && context instanceof Activity) {
hostView.postDelayed(new Runnable() {
@Override
public void run() {
View currentFocus = ((Activity) context).getCurrentFocus();
if (!(currentFocus instanceof EditText)) {
mInputMethodManager.hideSoftInputFromWindow(getHostView().getWindowToken(), 0);
}
}
}, 16);
}
}
}
示例4: onCreate
import android.widget.EditText; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_select_members);
textNoRecord = (TextView) findViewById(R.id.textEmpty);
listView = (ListView) findViewById(R.id.list_team_members);
listView.setOnItemClickListener(this);
memberList = new ArrayList<>();
editAddMembers = (EditText) findViewById(R.id.editAddTeamMember);
editAddMembers.addTextChangedListener(this);
findViewById(R.id.image_search).setOnClickListener(this);
try {
odoo = Odoo.createWithUser(this, OUser.current(this));
} catch (OdooVersionException e) {
e.printStackTrace();
}
}
示例5: setThemedContext
import android.widget.EditText; //导入依赖的package包/类
@Override
public void setThemedContext(ThemedReactContext themedContext) {
super.setThemedContext(themedContext);
// TODO #7120264: cache this stuff better
mEditText = new EditText(getThemedContext());
// This is needed to fix an android bug since 4.4.3 which will throw an NPE in measure,
// setting the layoutParams fixes it: https://code.google.com/p/android/issues/detail?id=75877
mEditText.setLayoutParams(
new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
setDefaultPadding(Spacing.START, mEditText.getPaddingStart());
setDefaultPadding(Spacing.TOP, mEditText.getPaddingTop());
setDefaultPadding(Spacing.END, mEditText.getPaddingEnd());
setDefaultPadding(Spacing.BOTTOM, mEditText.getPaddingBottom());
mEditText.setPadding(0, 0, 0, 0);
}
示例6: dispatchTouchEvent
import android.widget.EditText; //导入依赖的package包/类
@Override public boolean dispatchTouchEvent(MotionEvent ev) {
if (isAutoHideInputView) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
View v = getCurrentFocus();
if (v != null) {
if ((v instanceof EditText)) {
if (!AppUtils.isEventInVIew(v, ev)) {
if (AppUtils.hideInput(this, v) && isClearFocusWhileAutoHideInputView) {
v.clearFocus();
}
}
}
}
return super.dispatchTouchEvent(ev);
}
// 必不可少,否则所有的组件都不会有TouchEvent了
if (getWindow().superDispatchTouchEvent(ev)) {
return true;
}
}
try {
return super.dispatchTouchEvent(ev);
} catch (Exception e) {
// ignored
}
return false;
}
示例7: initViews
import android.widget.EditText; //导入依赖的package包/类
private void initViews() {
latitudeInput = (EditText) findViewById(R.id.latitude_input);
longitudeInput = (EditText) findViewById(R.id.longitude_input);
mockLocationView = (TextView) findViewById(R.id.mock_location_view);
updatedLocationView = (TextView) findViewById(R.id.updated_location_view);
mockModeToggleButton = (ToggleButton) findViewById(R.id.toggle_button);
setLocationButton = (Button) findViewById(R.id.set_location_button);
mockModeToggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
setMockMode(isChecked);
setLocationButton.setEnabled(isChecked);
}
});
setLocationButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
addMockLocation();
}
});
}
示例8: setUp
import android.widget.EditText; //导入依赖的package包/类
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
setupActivity = Robolectric.setupActivity(TestSetupActivity.class);
nicknameEntryWrapper = (TextInputLayout) setupActivity
.findViewById(R.id.nickname_entry_wrapper);
passwordConfirmationWrapper = (TextInputLayout) setupActivity
.findViewById(R.id.password_confirm_wrapper);
nicknameEntry =
(EditText) setupActivity.findViewById(R.id.nickname_entry);
passwordEntry =
(EditText) setupActivity.findViewById(R.id.password_entry);
passwordConfirmation =
(EditText) setupActivity.findViewById(R.id.password_confirm);
strengthMeter =
(StrengthMeter) setupActivity.findViewById(R.id.strength_meter);
createAccountButton =
(Button) setupActivity.findViewById(R.id.create_account);
}
示例9: onShowTab
import android.widget.EditText; //导入依赖的package包/类
@Override
public void onShowTab(@NonNull final Context context,
@NonNull final TabSwitcher tabSwitcher, @NonNull final View view,
@NonNull final Tab tab, final int index, final int viewType,
@Nullable final Bundle savedInstanceState) {
TextView textView = findViewById(android.R.id.title);
textView.setText(tab.getTitle());
Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setVisibility(tabSwitcher.isSwitcherShown() ? View.GONE : View.VISIBLE);
if (viewType != 0) {
EditText editText = findViewById(android.R.id.edit);
if (savedInstanceState == null) {
editText.setText(null);
}
editText.requestFocus();
}
}
示例10: loginErrorMessage
import android.widget.EditText; //导入依赖的package包/类
private void loginErrorMessage(String errorMessage, EditText email, EditText password){
if(errorMessage.equals(getString(R.string.msg_len_email_error_message))){
email.requestFocus();
email.setError("Email inválido. Tente novamente");
}
if(errorMessage.equals(getString(R.string.msg_special_characters_email_error_message))){
email.requestFocus();
email.setError("Email inválido. Tente novamente");
}
if(errorMessage.equals(getString(R.string.msg_null_email_error_message))){
email.requestFocus();
email.setError(getString(R.string.msg_null_email_error_message));
}
if(errorMessage.equals(getString(R.string.msg_len_password_error_message))){
password.requestFocus();
password.setError("Senha inválida. Tente Novamente");
}
if(errorMessage.equals(getString(R.string.msg_null_password_error_message))){
password.requestFocus();
password.setError(getString(R.string.msg_null_password_error_message));
}
}
示例11: onTouch
import android.widget.EditText; //导入依赖的package包/类
@Override
public boolean onTouch(View v, MotionEvent event) {
KeyboardUtils.hideSoftInput(mContext);
View currentFocus = mContext.getCurrentFocus();
//处理列表中的控件需要点击两次才生效的问题
if (currentFocus != v && v.isClickable() && event.getAction() == MotionEvent.ACTION_DOWN) {
v.requestFocus();
return false;
}
if (currentFocus instanceof EditText) {
mRootView.requestFocus();
}
return false;
}
示例12: onCreate
import android.widget.EditText; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
ActivitySectionDetailsBinding binding = DataBindingUtil.setContentView (this, R.layout.activity_section_details);
mSectionIndex = getIntent ().getIntExtra (GlobalData.SECTION_INDEX, 1); //TODO do has extra
Toolbar toolbar = (Toolbar) findViewById (R.id.toolbarSubDetail);
setSupportActionBar (toolbar);
android.support.v7.app.ActionBar actionBar = getSupportActionBar ();
Button updateButton = (Button) findViewById (R.id.update);
mSectionNameEditText = (EditText) findViewById (R.id.textViewSectionName);
mSectionDescriptionEditText = (EditText) findViewById (R.id.textViewDescriptionName);
updateButton.setOnClickListener (this);
// Toast.makeText (SectionDetailsActivity.this, "file id ="+getIntent ().getLongExtra (GlobalData.SECTION_INDEX,-1), Toast.LENGTH_LONG).show ();
mSubject = new SectionDetailsBinder (SectionDetailsActivity.this, mSectionIndex + 1);
mSubject.setInputType ("none");
binding.setSubject (mSubject);
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled (true);
}
}
示例13: onCreate
import android.widget.EditText; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_reguser);
System.out.println("reached here1232");
e_name=(EditText) findViewById(R.id.name);
e_username=(EditText) findViewById(R.id.r_userName);
e_password=(EditText) findViewById(R.id.password);
e_lifestyle=(Spinner) findViewById(R.id.lifestyle);
e_current_weight = (EditText) findViewById(R.id.cweight);
e_goal_weight = (EditText) findViewById(R.id.gweight);
e_lifestyle.setOnItemSelectedListener(this);
spinner = (ProgressBar)findViewById(R.id.progressBar2);
//getSupportActionBar().setDisplayHomeAsUpEnabled(true);
spinner.setVisibility(View.GONE);
}
示例14: setCursorColor
import android.widget.EditText; //导入依赖的package包/类
public static void setCursorColor(EditText editText, int color) {
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);
Drawable[] drawables = new Drawable[2];
drawables[0] = ContextCompat.getDrawable(editText.getContext(), mCursorDrawableRes);
drawables[1] = ContextCompat.getDrawable(editText.getContext(), mCursorDrawableRes);
drawables[0].setColorFilter(color, PorterDuff.Mode.SRC_IN);
drawables[1].setColorFilter(color, PorterDuff.Mode.SRC_IN);
fCursorDrawable.set(editor, drawables);
} catch (final Throwable ignored) { }
}
示例15: onViewCreated
import android.widget.EditText; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
btn_find = (Button) view.findViewById(R.id.btn_find);
et_location_name = (EditText) view.findViewById(R.id.et_location_name);
et_country_code = (EditText) view.findViewById(R.id.et_country_code);
et_countyISO = (EditText) view.findViewById(R.id.et_countyISO);
et_currencyCode = (EditText) view.findViewById(R.id.et_currencyCode);
tv_currencySymbol = (TextView) view.findViewById(R.id.tv_currencySymbol);
tv_currencyDisplayName = (TextView) view.findViewById(R.id.tv_currencyDisplayName);
tv_currencyCode = (TextView) view.findViewById(R.id.tv_currencyCode);
tv_fractionDigits = (TextView) view.findViewById(R.id.tv_fractionDigits);
tv_numericCode = (TextView) view.findViewById(R.id.tv_numericCode);
tv_noDataFound = (TextView) view.findViewById(R.id.tv_noDataFound);
fl_bottomContents = (FrameLayout) view.findViewById(R.id.fl_bottomContents);
availableCurrenciesSet = Currency.getAvailableCurrencies();
currencyList = new ArrayList<>(availableCurrenciesSet);
btn_find.setOnClickListener(this);
}