android.widget.EditText#setOnTouchListener ( )源码实例Demo

下面列出了android.widget.EditText#setOnTouchListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: QuickNews   文件: SearchActivity.java
private void initView(){
    mIvBack= (ImageView) findViewById(R.id.ivBack);
    mEtInput= (EditText) findViewById(R.id.etInput);
    mIvClear= (ImageView) findViewById(R.id.ivClearText);
    mTvSearch= (TextView) findViewById(R.id.tvSearchEnsure);
    mLvSearchResult= (ListView) findViewById(R.id.lvSearchResult);
    mProgressBar= (ProgressBar) findViewById(R.id.pbSearchProgress);

    mTvSearch.setClickable(true);
    mTvSearch.setOnClickListener(this);
    mIvClear.setOnClickListener(this);
    mIvBack.setOnClickListener(this);

    mEtInput.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            mEtInput.setFocusable(true);
            mEtInput.setFocusableInTouchMode(true);
            mEtInput.requestFocus();
            return false;
        }
    });
}
 
源代码2 项目: Pinview   文件: Pinview.java
/**
 * Takes care of styling the editText passed in the param.
 * tag is the index of the editText.
 *
 * @param styleEditText
 * @param tag
 */
private void generateOneEditText(EditText styleEditText, String tag) {
    params.setMargins(mSplitWidth / 2, mSplitWidth / 2, mSplitWidth / 2, mSplitWidth / 2);
    filters[0] = new InputFilter.LengthFilter(1);
    styleEditText.setFilters(filters);
    styleEditText.setLayoutParams(params);
    styleEditText.setGravity(Gravity.CENTER);
    styleEditText.setCursorVisible(mCursorVisible);

    if (!mCursorVisible) {
        styleEditText.setClickable(false);
        styleEditText.setHint(mHint);

        styleEditText.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                // When back space is pressed it goes to delete mode and when u click on an edit Text it should get out of the delete mode
                mDelPressed = false;
                return false;
            }
        });
    }
    styleEditText.setBackgroundResource(mPinBackground);
    styleEditText.setPadding(0, 0, 0, 0);
    styleEditText.setTag(tag);
    styleEditText.setInputType(getKeyboardInputType());
    styleEditText.addTextChangedListener(this);
    styleEditText.setOnFocusChangeListener(this);
    styleEditText.setOnKeyListener(this);
}
 
源代码3 项目: AppLocker   文件: LockActivity.java
protected void setupEditText(EditText editText) {
	editText.setInputType(InputType.TYPE_NULL);
	editText.setFilters(filters);
	editText.setOnTouchListener(touchListener);
	editText.setTransformationMethod(PasswordTransformationMethod
			.getInstance());
}
 
源代码4 项目: science-journal   文件: LabelDetailsFragment.java
protected void setupCaption(View rootView) {
  caption = (EditText) rootView.findViewById(R.id.caption);
  caption.setText(originalLabel.getCaptionText());
  caption.setImeOptions(EditorInfo.IME_ACTION_DONE);
  caption.setRawInputType(InputType.TYPE_CLASS_TEXT);
  caption.setOnEditorActionListener(
      (textView, i, keyEvent) -> {
        if (i == EditorInfo.IME_ACTION_DONE) {
          caption.clearFocus();
          caption.setFocusable(false);
        }
        return false;
      });
  caption.setOnTouchListener(
      (v, motionEvent) -> {
        caption.setFocusableInTouchMode(true);
        caption.requestFocus();
        return false;
      });

  caption.setEnabled(false);
  experiment
      .firstElement()
      .subscribe(
          experiment -> {
            caption.setEnabled(true);
            // Move the cursor to the end
            caption.post(() -> caption.setSelection(caption.getText().toString().length()));

            saved
                .happens()
                .subscribe(o -> saveCaptionChanges(experiment, caption.getText().toString()));
          });
}
 
源代码5 项目: AppLocker   文件: LockActivity.java
protected void setupEditText(EditText editText) {
	editText.setInputType(InputType.TYPE_NULL);
	editText.setFilters(filters);
	editText.setOnTouchListener(touchListener);
	editText.setTransformationMethod(PasswordTransformationMethod
			.getInstance());
}
 
源代码6 项目: AndroidSecurityKeyboard   文件: SecKeyboardView.java
public SecKeyboardView(Activity act, final EditText editText, KeyboardView keyboardView) {

        Activity activity = act;
        this.ed = editText;
        this.mKeyboardView = keyboardView;

        alphabetKeyBoard = new Keyboard(activity, R.xml.qwerty);
        numberKeyBoard = new Keyboard(activity, R.xml.number);
        symbolKeyBoard = new Keyboard(activity, R.xml.symbols);

        mImm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);

        mKeyboardView.setKeyboard(alphabetKeyBoard);
        mKeyboardView.setEnabled(true);
        mKeyboardView.setPreviewEnabled(false);
        mKeyboardView.setOnKeyboardActionListener(listener);

        editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View view, boolean b) {
                if (!b) {
                    hideKeyboard();
                } else {
                    mImm.hideSoftInputFromWindow(view.getWindowToken(), 0); //强制隐藏键盘
                }
            }
        });
        editText.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                int inputType = editText.getInputType();
                hideSoftInputMethod(editText);
                showKeyboard();
                editText.setInputType(inputType);
                return false;
            }
        });
    }
 
源代码7 项目: bither-android   文件: EntryKeyboardView.java
public EntryKeyboardView registerEditText(EditText... ets) {
    for (EditText et : ets) {
        et.setOnFocusChangeListener(this);
        et.setOnClickListener(this);
        et.setOnTouchListener(this);
    }
    return this;
}
 
源代码8 项目: dttv-android   文件: AddUrlDialog.java
private void findView() {
    ed_coupon_no=(EditText) findViewById(R.id.ed_coupon_no);
    dialog_button_ok=(Button) findViewById(R.id.dialog_button_ok);
    dialog_button_sdp = (Button)findViewById(R.id.dialog_button_sdp);
    ed_coupon_no.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return false;
        }
    });

}
 
源代码9 项目: android_maplibui   文件: ControlHelper.java
public static void setClearAction(final EditText target)
{
    target.setOnTouchListener(new View.OnTouchListener()
    {
        final int RIGHT = 2;

        @Override
        public boolean onTouch(
                View view,
                MotionEvent event)
        {
            if (event.getAction() == MotionEvent.ACTION_UP) {
                int leftEdgeOfRightDrawable =
                        view.getRight() - target.getCompoundDrawables()[RIGHT].getBounds()
                                .width();
                // when EditBox has padding, adjust leftEdge like
                // leftEdgeOfRightDrawable -= getResources().getDimension(R.dimen.edittext_padding_left_right);
                if (event.getRawX() >= leftEdgeOfRightDrawable) {
                    // clicked on clear icon
                    target.setText("");
                    target.clearFocus();
                    return false;
                }
            }
            return false;
        }
    });
}
 
源代码10 项目: AppLock   文件: AppLockActivity.java
protected void setupEditText(EditText editText) {
	editText.setInputType(InputType.TYPE_NULL);
	editText.setFilters(filters);
	editText.setOnTouchListener(touchListener);
	editText.setTransformationMethod(PasswordTransformationMethod
			.getInstance());
}
 
源代码11 项目: YiBo   文件: EditDirectMessageActivity.java
private void bindEvent() {
	Button btnBack = (Button) this.findViewById(R.id.btnBack);
	btnBack.setOnClickListener(new GoBackClickListener());

	Button btnSend = (Button) this.findViewById(R.id.btnOperate);
	btnSend.setText(R.string.label_send);
	btnSend.setVisibility(View.VISIBLE);
	btnSend.setOnClickListener(new EditDirectMessageSendClickListener(this));

	Button btnUserSelector = (Button) this.findViewById(R.id.btnUserSelector);
	//btnUserSelector.setOnClickListener(new EditDirectMessageUserSelectorClickListener(this));
	EditMicroBlogMentionClickListener userSelectorListener = new EditMicroBlogMentionClickListener();
	userSelectorListener.setRequestCode(Constants.REQUEST_CODE_USER_SELECTOR_MESSAGE);
	userSelectorListener.setSelectMode(SelectMode.Single);
	userSelectorListener.setTitleId(R.string.title_select_recipient);
	btnUserSelector.setOnClickListener(userSelectorListener);

	EditText etText = (EditText) this.findViewById(R.id.etText);
	etText.addTextChangedListener(new MicroBlogTextWatcher(this));
	etText.setOnTouchListener(hideEmotionGridListener);

	Button btnTopic = (Button) this.findViewById(R.id.btnTopic);
	btnTopic.setOnClickListener(new EditMicroBlogTopicClickListener(this));

	Button btnEmotion = (Button) this.findViewById(R.id.btnEmotion);
	btnEmotion.setOnClickListener(new EditMicroBlogEmotionClickListener(this));

    Button btnMention = (Button) this.findViewById(R.id.btnMention);
    btnMention.setOnClickListener(new EditMicroBlogMentionClickListener());

    Button btnTextCount = (Button) this.findViewById(R.id.btnTextCount);
    btnTextCount.setOnClickListener(new EditMicroBlogTextDeleteClickListener(this));
}
 
protected void setupPinItem(EditText item){
    item.setInputType(InputType.TYPE_NULL);
    item.setFilters(filters);
    item.setOnTouchListener(otl);
    item.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
 
源代码13 项目: Cirrus_depricated   文件: AuthenticatorActivity.java
/**
 * 
 * @param savedInstanceState        Saved activity state, as in {{@link #onCreate(Bundle)}
 */
private void initAuthorizationPreFragment(Bundle savedInstanceState) {
    
    /// step 0 - get UI elements in layout
    mOAuth2Check = (CheckBox) findViewById(R.id.oauth_onOff_check);
    mOAuthAuthEndpointText = (TextView)findViewById(R.id.oAuthEntryPoint_1);
    mOAuthTokenEndpointText = (TextView)findViewById(R.id.oAuthEntryPoint_2);
    mUsernameInput = (EditText) findViewById(R.id.account_username);
    mPasswordInput = (EditText) findViewById(R.id.account_password);
    mPasswordInput.setTypeface(mUsernameInput.getTypeface());
    mAuthStatusView = (TextView) findViewById(R.id.auth_status_text); 
    
    /// step 1 - load and process relevant inputs (resources, intent, savedInstanceState)
    String presetUserName = null;
    boolean isPasswordExposed = false;
    if (savedInstanceState == null) {
        if (mAccount != null) {
            presetUserName = mAccount.name.substring(0, mAccount.name.lastIndexOf('@'));
        }
        
    } else {
        isPasswordExposed = savedInstanceState.getBoolean(KEY_PASSWORD_EXPOSED, false);
        mAuthStatusText = savedInstanceState.getInt(KEY_AUTH_STATUS_TEXT);
        mAuthStatusIcon = savedInstanceState.getInt(KEY_AUTH_STATUS_ICON);
        mAuthToken = savedInstanceState.getString(KEY_AUTH_TOKEN);
    }
    
    /// step 2 - set properties of UI elements (text, visibility, enabled...)
    mOAuth2Check.setChecked(
            AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType())
                .equals(mAuthTokenType));
    if (presetUserName != null) {
        mUsernameInput.setText(presetUserName);
    }
    if (mAction != ACTION_CREATE) {
        mUsernameInput.setEnabled(false);
        mUsernameInput.setFocusable(false);
    }
    mPasswordInput.setText(""); // clean password to avoid social hacking
    if (isPasswordExposed) {
        showPassword();
    }
    updateAuthenticationPreFragmentVisibility();
    showAuthStatus();
    mOkButton.setEnabled(mServerIsValid);

    
    /// step 3 - bind listeners
    // bindings for password input field
    mPasswordInput.setOnFocusChangeListener(this);
    mPasswordInput.setImeOptions(EditorInfo.IME_ACTION_DONE);
    mPasswordInput.setOnEditorActionListener(this);
    mPasswordInput.setOnTouchListener(new RightDrawableOnTouchListener() {
        @Override
        public boolean onDrawableTouch(final MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
                AuthenticatorActivity.this.onViewPasswordClick();
            }
            return true;
        }
    });
    
}
 
源代码14 项目: openshop.io-android   文件: LoginDialogFragment.java
private void prepareInputBoxes(View view) {
    // Registration form
    loginRegistrationEmailWrapper = view.findViewById(R.id.login_registration_email_wrapper);
    loginRegistrationPasswordWrapper = view.findViewById(R.id.login_registration_password_wrapper);
    loginRegistrationGenderWoman = view.findViewById(R.id.login_registration_sex_woman);
    EditText registrationPassword = loginRegistrationPasswordWrapper.getEditText();
    if (registrationPassword != null) {
        registrationPassword.setOnTouchListener(new OnTouchPasswordListener(registrationPassword));
    }


    // Login email form
    loginEmailEmailWrapper = view.findViewById(R.id.login_email_email_wrapper);
    EditText loginEmail = loginEmailEmailWrapper.getEditText();
    if (loginEmail != null) loginEmail.setText(SettingsMy.getUserEmailHint());
    loginEmailPasswordWrapper = view.findViewById(R.id.login_email_password_wrapper);
    EditText emailPassword = loginEmailPasswordWrapper.getEditText();
    if (emailPassword != null) {
        emailPassword.setOnTouchListener(new OnTouchPasswordListener(emailPassword));
        emailPassword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_SEND || actionId == 124) {
                    invokeLoginWithEmail();
                    return true;
                }
                return false;
            }
        });
    }

    loginEmailForgottenEmailWrapper = view.findViewById(R.id.login_email_forgotten_email_wrapper);
    EditText emailForgottenPassword = loginEmailForgottenEmailWrapper.getEditText();
    if (emailForgottenPassword != null)
        emailForgottenPassword.setText(SettingsMy.getUserEmailHint());

    // Simple accounts whisperer.
    Account[] accounts = AccountManager.get(getActivity()).getAccounts();
    String[] addresses = new String[accounts.length];
    for (int i = 0; i < accounts.length; i++) {
        addresses[i] = accounts[i].name;
        Timber.e("Sets autocompleteEmails: %s", accounts[i].name);
    }

    ArrayAdapter<String> emails = new ArrayAdapter<>(getActivity(), android.R.layout.simple_dropdown_item_1line, addresses);
    AutoCompleteTextView textView = view.findViewById(R.id.login_registration_email_text_auto);
    textView.setAdapter(emails);
}
 
protected void setupPinItem(EditText item){
    item.setInputType(InputType.TYPE_NULL); 
    item.setFilters(filters); 
    item.setOnTouchListener(otl);
    item.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
 
protected void setupPinItem(EditText item){
    item.setInputType(InputType.TYPE_NULL); 
    item.setFilters(filters); 
    item.setOnTouchListener(otl);
    item.setTransformationMethod(PasswordTransformationMethod.getInstance());
}