當前位置: 首頁>>代碼示例>>Java>>正文


Java EditText類代碼示例

本文整理匯總了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();
        }
    });
}
 
開發者ID:zak0,項目名稱:AppTycoon,代碼行數:21,代碼來源:ChangeProductNameDialog.java

示例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);
    }
  }
}
 
開發者ID:erguotou520,項目名稱:weex-uikit,代碼行數:18,代碼來源:AbstractEditComponent.java

示例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();
    }
}
 
開發者ID:odoo-mobile-intern,項目名稱:odoo-work,代碼行數:22,代碼來源:SelectMembers.java

示例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);
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:20,代碼來源:ReactTextInputShadowNode.java

示例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;
}
 
開發者ID:Lingzh0ng,項目名稱:BrotherWeather,代碼行數:29,代碼來源:BaseActivity.java

示例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();
        }
    });
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:23,代碼來源:MockLocationsActivity.java

示例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);
}
 
開發者ID:rafjordao,項目名稱:Nird2,代碼行數:20,代碼來源:SetupActivityTest.java

示例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();
    }
}
 
開發者ID:michael-rapp,項目名稱:ChromeLikeTabSwitcher,代碼行數:21,代碼來源:MainActivity.java

示例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));
    }
}
 
開發者ID:fga-gpp-mds,項目名稱:2017.1-Trezentos,代碼行數:27,代碼來源:LoginActivity.java

示例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;
}
 
開發者ID:SpannerBear,項目名稱:ValueAddSubView,代碼行數:16,代碼來源:FocusManager.java

示例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);
        }
    }
 
開發者ID:atulgpt,項目名稱:TimeTrix,代碼行數:21,代碼來源:SectionDetailsActivity.java

示例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);
}
 
開發者ID:PallabPaul,項目名稱:AI_Calorie_Counter_Demo,代碼行數:17,代碼來源:reguser.java

示例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) {  }
}
 
開發者ID:HoraApps,項目名稱:Liz,代碼行數:22,代碼來源:ThemeHelper.java

示例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);
}
 
開發者ID:Fenscode,項目名稱:FindCurrencyExa,代碼行數:22,代碼來源:MainFragment.java


注:本文中的android.widget.EditText類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。