Java Code Examples for android.widget.EditText#setOnFocusChangeListener()

The following examples show how to use android.widget.EditText#setOnFocusChangeListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BCCAssetsDetectHotActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
private void initView() {
    findViewById(R.id.ibtn_cancel).setOnClickListener(
            new IBackClickListener(0, R.anim.slide_out_right));
    tvBalance = (TextView) findViewById(R.id.tv_balance);
    tvAddressLabel = (TextView) findViewById(R.id.tv_address_label);
    etAddress = (EditText) findViewById(R.id.et_address);
    ibtnScan = (ImageButton) findViewById(R.id.ibtn_scan);
    btnSend = (Button) findViewById(R.id.btn_send);
    etPassword = (EditText) findViewById(R.id.et_password);
    tvBccSendTitle = (TextView)findViewById(R.id.bcc_send_title);
    kvPassword = (PasswordEntryKeyboardView) findViewById(R.id.kv_password);
    vKeyboardContainer = findViewById(R.id.v_keyboard_container);
    etPassword.addTextChangedListener(passwordWatcher);
    etPassword.setOnEditorActionListener(passwordAction);

    BCCAssetsDetectHotActivity.ReceivingAddressListener addressListener = new BCCAssetsDetectHotActivity.ReceivingAddressListener();
    etAddress.setOnFocusChangeListener(addressListener);
    etAddress.addTextChangedListener(addressListener);
    dp = new DialogRCheck(this);
    tvBccSendTitle.setText(getString(R.string.extract_assets_BCC_send_title));
    btnSend.setText(getString(R.string.extract_assets));

    ibtnScan.setOnClickListener(scanClick);
    btnSend.setOnClickListener(sendClick);
    kvPassword.registerEditText(etPassword).setListener(this);
}
 
Example 2
Source File: NumberPicker.java    From screenstandby with GNU General Public License v2.0 6 votes vote down vote up
public NumberPicker(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs);
    setOrientation(VERTICAL);
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.number_picker, this, true);
    mHandler = new Handler();
    InputFilter inputFilter = new NumberPickerInputFilter();
    mNumberInputFilter = new NumberRangeKeyListener();
    mIncrementButton = (NumberPickerButton) findViewById(R.id.increment);
    mIncrementButton.setOnClickListener(this);
    mIncrementButton.setOnLongClickListener(this);
    mIncrementButton.setNumberPicker(this);
    mDecrementButton = (NumberPickerButton) findViewById(R.id.decrement);
    mDecrementButton.setOnClickListener(this);
    mDecrementButton.setOnLongClickListener(this);
    mDecrementButton.setNumberPicker(this);

    mText = (EditText) findViewById(R.id.timepicker_input);
    mText.setOnFocusChangeListener(this);
    mText.setFilters(new InputFilter[] {inputFilter});
    mText.setRawInputType(InputType.TYPE_CLASS_NUMBER);

    if (!isEnabled()) {
        setEnabled(false);
    }
}
 
Example 3
Source File: SoftKeyboard.java    From iGap-Android with GNU Affero General Public License v3.0 6 votes vote down vote up
private void initEditTexts(ViewGroup viewgroup) {
    if (editTextList == null) editTextList = new ArrayList<EditText>();

    int childCount = viewgroup.getChildCount();
    for (int i = 0; i <= childCount - 1; i++) {
        View v = viewgroup.getChildAt(i);

        if (v instanceof ViewGroup) {
            initEditTexts((ViewGroup) v);
        }

        if (v instanceof EditText) {
            EditText editText = (EditText) v;
            editText.setOnFocusChangeListener(this);
            editText.setCursorVisible(true);
            editTextList.add(editText);
        }
    }
}
 
Example 4
Source File: BaseKeyboard.java    From actor-platform with GNU Affero General Public License v3.0 6 votes vote down vote up
public BaseKeyboard(Activity activity, EditText messageBody) {
    this.activity = activity;
    this.windowManager = activity.getWindowManager();
    this.inputMethodManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    this.decorView = activity.getWindow().getDecorView();
    decorView.getViewTreeObserver().addOnGlobalLayoutListener(this);
    //setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
    //default size
    keyboardHeight = (int) activity.getResources().getDimension(R.dimen.keyboard_height);
    keyboardHelper = new KeyboardHelper(activity);
    this.messageBody = messageBody;

    messageBody.setOnClickListener(view -> {
        if (showing) {
            dismiss();
        }
    });
    messageBody.setOnFocusChangeListener((view, b) -> {
        if (b && showing) {
            dismiss();
        }
    });

}
 
Example 5
Source File: PinViewBaseHelper.java    From PinView with Apache License 2.0 6 votes vote down vote up
/**
 * Generate a PinBox {@link EditText} with all attributes to add to {@link PinView}
 *
 * @param i index of new PinBox
 * @param inputType inputType to new PinBox
 * @return new PinBox
 */
EditText generatePinBox(int i, int inputType) {
    EditText editText = (EditText) LayoutInflater.from(getContext()).inflate(R.layout.partial_pin_box, this, false);
    int generateViewId = PinViewUtils.generateViewId();
    editText.setId(generateViewId);
    editText.setTag(i);
    if (inputType != -1) {
        editText.setInputType(inputType);
    }
    setStylePinBox(editText);

    editText.addTextChangedListener(this);
    editText.setOnFocusChangeListener(this);
    pinBoxesIds[i] = generateViewId;

    return editText;
}
 
Example 6
Source File: RegisteActivity.java    From LoveTalkClient with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	setContentView(R.layout.activity_registe);

	usernametext = (EditText) findViewById(R.id.usernametext);
	emailtext = (EditText) findViewById(R.id.emailtext);
	passtext = (EditText) findViewById(R.id.passtext);
	pass2text = (EditText) findViewById(R.id.pass2text);
	mobiletext = (EditText) findViewById(R.id.mobiletext);
	back = (ImageView) findViewById(R.id.back);
	next = (ImageView) findViewById(R.id.next);
	sexgGroup = (RadioGroup) findViewById(R.id.sex);

	back.setOnClickListener(this);
	next.setOnClickListener(this);
	usernametext.setOnFocusChangeListener(this);
	emailtext.setOnFocusChangeListener(this);
	passtext.setOnFocusChangeListener(this);
	pass2text.setOnFocusChangeListener(this);
	mobiletext.setOnFocusChangeListener(this);
}
 
Example 7
Source File: HyperTextEditor.java    From YCCustomText with Apache License 2.0 6 votes vote down vote up
/**
 * 添加生成文本输入框
 * @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;
}
 
Example 8
Source File: NumberPicker.java    From financisto with GNU General Public License v2.0 6 votes vote down vote up
public NumberPicker(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs);
    setOrientation(VERTICAL);
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.number_picker, this, true);
    mHandler = new Handler();
    InputFilter inputFilter = new NumberPickerInputFilter();
    mNumberInputFilter = new NumberRangeKeyListener();
    mIncrementButton = (NumberPickerButton) findViewById(R.id.increment);
    mIncrementButton.setOnClickListener(this);
    mIncrementButton.setOnLongClickListener(this);
    mIncrementButton.setNumberPicker(this);
    mDecrementButton = (NumberPickerButton) findViewById(R.id.decrement);
    mDecrementButton.setOnClickListener(this);
    mDecrementButton.setOnLongClickListener(this);
    mDecrementButton.setNumberPicker(this);
    
    mText = (EditText) findViewById(R.id.timepicker_input);
    mText.setOnFocusChangeListener(this);
    mText.setFilters(new InputFilter[] {inputFilter});
    mText.setRawInputType(InputType.TYPE_CLASS_NUMBER);

    if (!isEnabled()) {
        setEnabled(false);
    }
}
 
Example 9
Source File: AddCollectionActivity.java    From Expert-Android-Programming with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add_collection);

    toolbar = (Toolbar) findViewById(R.id.toolbar1);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle("Create a Collection");
    toolbar.setTitleTextColor(ContextCompat.getColor(context, R.color.white));

    collectionName = (EditText) findViewById(R.id.collectionName);
    collectionNameLine = (ImageView) findViewById(R.id.collectionNameLine);
    collectionNameCancel = (ImageView) findViewById(R.id.collectionNameCancel);

    description = (EditText) findViewById(R.id.description);
    descriptionLine = (ImageView) findViewById(R.id.descriptionLine);
    descriptionCancel = (ImageView) findViewById(R.id.descriptionCancel);

    tag = (EditText) findViewById(R.id.tag);
    tagLine = (ImageView) findViewById(R.id.tagLine);
    tagCancel = (ImageView) findViewById(R.id.tagCancel);

    //For Focus
    collectionName.setOnFocusChangeListener(hasFocusListener);
    description.setOnFocusChangeListener(hasFocusListener);
    tag.setOnFocusChangeListener(hasFocusListener);

    //For TextChange
    collectionName.addTextChangedListener(textLengthListener);
    description.addTextChangedListener(textLengthListener);
    tag.addTextChangedListener(textLengthListener);

}
 
Example 10
Source File: GenerateUnsignedTxActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void initView() {
    findViewById(R.id.ibtn_cancel).setOnClickListener(new IBackClickListener());
    tvAddressLabel = (TextView) findViewById(R.id.tv_address_label);
    etAddress = (EditText) findViewById(R.id.et_address);
    ibtnScan = (ImageButton) findViewById(R.id.ibtn_scan);
    btnSend = (Button) findViewById(R.id.btn_send);
    tvBalance = (TextView) findViewById(R.id.tv_balance);
    ivBalanceSymbol = (ImageView) findViewById(R.id.iv_balance_symbol);
    tvBalance.setText(UnitUtilWrapper.formatValue(address.getBalance()));
    ivBalanceSymbol.setImageBitmap(UnitUtilWrapper.getBtcSymbol(tvBalance));
    kvAmount = (AmountEntryKeyboardView) findViewById(R.id.kv_amount);
    vKeyboardContainer = findViewById(R.id.v_keyboard_container);
    findViewById(R.id.ibtn_option).setOnClickListener(optionClick);
    dialogSelectChangeAddress = new DialogSelectChangeAddress(this, address);
    final CurrencyAmountView btcAmountView = (CurrencyAmountView) findViewById(R.id.cav_btc);
    btcAmountView.setCurrencySymbol(getString(R.string.bitcoin_symbol));
    int precision = (int) Math.floor(Math.log10(AppSharedPreference.getInstance()
            .getBitcoinUnit().satoshis));
    btcAmountView.setInputPrecision(precision);
    btcAmountView.setHintPrecision(Math.min(4, precision));
    btcAmountView.setShift(8 - precision);

    final CurrencyAmountView localAmountView = (CurrencyAmountView) findViewById(R.id
            .cav_local);
    localAmountView.setInputPrecision(2);
    localAmountView.setHintPrecision(2);
    amountCalculatorLink = new CurrencyCalculatorLink(btcAmountView, localAmountView);
    ReceivingAddressListener addressListener = new ReceivingAddressListener();
    etAddress.setOnFocusChangeListener(addressListener);
    etAddress.addTextChangedListener(addressListener);
    dp = new DialogRCheck(this);
    ibtnScan.setOnClickListener(scanClick);
    btnSend.setOnClickListener(sendClick);
    kvAmount.registerEditText((EditText) findViewById(R.id.send_coins_amount_btc_edittext),
            (EditText) findViewById(R.id.send_coins_amount_local_edittext)).setListener(this);
    findViewById(R.id.ll_balance).setOnClickListener(balanceClick);
}
 
Example 11
Source File: PinView.java    From PinView with Apache License 2.0 5 votes vote down vote up
/**
 * Clear PinBoxes focus
 */
public void resetChildrenFocus() {
    for (int pinBoxesId : pinBoxesIds) {
        EditText pin = (EditText) findViewById(pinBoxesId);
        pin.setOnFocusChangeListener(this);
    }
}
 
Example 12
Source File: MessageInput.java    From ChatKit with Apache License 2.0 5 votes vote down vote up
private void init(Context context) {
    inflate(context, R.layout.view_message_input, this);

    messageInput = (EditText) findViewById(R.id.messageInput);
    messageSendButton = (ImageButton) findViewById(R.id.messageSendButton);
    attachmentButton = (ImageButton) findViewById(R.id.attachmentButton);
    sendButtonSpace = (Space) findViewById(R.id.sendButtonSpace);
    attachmentButtonSpace = (Space) findViewById(R.id.attachmentButtonSpace);

    messageSendButton.setOnClickListener(this);
    attachmentButton.setOnClickListener(this);
    messageInput.addTextChangedListener(this);
    messageInput.setText("");
    messageInput.setOnFocusChangeListener(this);
}
 
Example 13
Source File: EditorView.java    From Nimbus with GNU General Public License v3.0 5 votes vote down vote up
private EditText createEditText(String hint, int Padding) {
    EditText editText = (EditText) inflater.inflate(R.layout.item_edittext, null);
    editText.setTag(viewTag++);
    editText.setOnFocusChangeListener(focusChangeListener);
    editText.setOnKeyListener(keyListener);
    editText.setPadding(dip2px(EDIT_PADDING_TOP), Padding, dip2px(EDIT_PADDING_TOP), 0);
    editText.setHint(hint);
    return editText;
}
 
Example 14
Source File: DelayedHintHelper.java    From Pix-Art-Messenger with GNU General Public License v3.0 5 votes vote down vote up
public static void setHint(@StringRes final int res, EditText editText) {
    editText.setOnFocusChangeListener((v, hasFocus) -> {
        if (hasFocus) {
            new Handler().postDelayed(() -> editText.setHint(res), 200);
        } else {
            editText.setHint(null);
        }
    });
}
 
Example 15
Source File: EntryKeyboardView.java    From bither-android with Apache License 2.0 5 votes vote down vote up
public EntryKeyboardView registerEditText(EditText... ets) {
    for (EditText et : ets) {
        et.setOnFocusChangeListener(this);
        et.setOnClickListener(this);
        et.setOnTouchListener(this);
    }
    return this;
}
 
Example 16
Source File: DelayedHintHelper.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
public static void setHint(@StringRes final int res, EditText editText) {
	editText.setOnFocusChangeListener((v, hasFocus) -> {
		if (hasFocus) {
			new Handler().postDelayed(() -> editText.setHint(res), 200);
		} else {
			editText.setHint(null);
		}
	});
}
 
Example 17
Source File: ChatActivity.java    From TestChat with Apache License 2.0 4 votes vote down vote up
private void initBottomView() {
        add = (Button) findViewById(R.id.btn_chat_bottom_add);
        emotion = (Button) findViewById(R.id.btn_chat_bottom_emotion);
        input = (EditText) findViewById(R.id.et_chat_bottom_input);
        speak = (Button) findViewById(R.id.btn_chat_bottom_speak);
        send = (Button) findViewById(R.id.btn_chat_bottom_send);
        voice = (Button) findViewById(R.id.btn_chat_bottom_voice);
        keyboard = (Button) findViewById(R.id.btn_chat_bottom_keyboard);
        l1_more = (LinearLayout) findViewById(R.id.l1_chat_bottom_more);
        mViewPager = (ViewPager) findViewById(R.id.vp_chat_bottom_emotion);
        r1_emotion = (RelativeLayout) findViewById(R.id.r1_chat_bottom_emotion);
        l1_add = (LinearLayout) findViewById(R.id.l1_chat_bottom_add);
        picture = (TextView) findViewById(R.id.tv_chat_bottom_picture);
        camera = (TextView) findViewById(R.id.tv_chat_bottom_camera);
        location = (TextView) findViewById(R.id.tv_chat_bottom_location);
        add.setOnClickListener(this);
        emotion.setOnClickListener(this);
        input.addTextChangedListener(this);
        input.setOnFocusChangeListener(new View.OnFocusChangeListener() {
                @Override
                public void onFocusChange(View v, boolean hasFocus) {
                        if (hasFocus) {
                                LogUtil.e("聚焦");
                                scrollToBottom();
                                if (l1_more.getVisibility() == View.VISIBLE) {
                                        l1_more.setVisibility(View.GONE);
                                }
                        }
                }
        });
        voice.setOnClickListener(this);
        send.setOnClickListener(this);
        keyboard.setOnClickListener(this);
        location.setOnClickListener(this);
        picture.setOnClickListener(this);
        camera.setOnClickListener(this);
        speak.setOnTouchListener(this);
        mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
                @Override
                public void onRefresh() {
                        mSwipeRefreshLayout.setRefreshing(true);
                        BaseMessage message = mAdapter.getData(0);
                        LoadMessage(message);
                }
        });
}
 
Example 18
Source File: AccountActivity.java    From Zom-Android-XMPP with GNU General Public License v3.0 4 votes vote down vote up
private void setupUIPre ()
    {
        ((ImApp)getApplication()).setAppTheme(this);

        setContentView(R.layout.account_activity);

        getSupportActionBar().setHomeButtonEnabled(true);

        mIsNewAccount = getIntent().getBooleanExtra("register", false);

        mEditUserAccount = (EditText) findViewById(R.id.edtName);
        mEditUserAccount.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                checkUserChanged();
            }
        });

        mEditPass = (EditText) findViewById(R.id.edtPass);

        mEditPassConfirm = (EditText) findViewById(R.id.edtPassConfirm);
        mSpinnerDomains = (AutoCompleteTextView) findViewById(R.id.spinnerDomains);

        if (mIsNewAccount)
        {
            mEditPassConfirm.setVisibility(View.VISIBLE);
            mSpinnerDomains.setVisibility(View.VISIBLE);
            mEditUserAccount.setHint(R.string.account_setup_new_username);

            /*
            ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                    android.R.layout.simple_dropdown_item_1line, getResources().getStringArray(R.array.account_domains));
            mSpinnerDomains.setAdapter(adapter);
            */

        }

        //mRememberPass = (CheckBox) findViewById(R.id.rememberPassword);
        //mUseTor = (CheckBox) findViewById(R.id.useTor);


       // mBtnSignIn = (Button) findViewById(R.id.btnSignIn);

//        if (mIsNewAccount)
  //          mBtnSignIn.setText(R.string.btn_create_new_account);

        mBtnAdvanced = (Button) findViewById(R.id.btnAdvanced);

        /**
        mRememberPass.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                updateWidgetState();
            }
        });*/

    }
 
Example 19
Source File: LoginViewModel.java    From android-MVVM-DataBinding-FormExample with MIT License 4 votes vote down vote up
@BindingAdapter("onFocus")
public static void bindFocusChange(EditText editText, View.OnFocusChangeListener onFocusChangeListener) {
    if (editText.getOnFocusChangeListener() == null) {
        editText.setOnFocusChangeListener(onFocusChangeListener);
    }
}
 
Example 20
Source File: AccountActivity.java    From zom-android-matrix with Apache License 2.0 4 votes vote down vote up
private void setupUIPre ()
    {
        ((ImApp)getApplication()).setAppTheme(this);

        setContentView(R.layout.account_activity);

        getSupportActionBar().setHomeButtonEnabled(true);

        mIsNewAccount = getIntent().getBooleanExtra("register", false);

        mEditUserAccount = (EditText) findViewById(R.id.edtName);
        mEditUserAccount.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                checkUserChanged();
            }
        });

        mEditPass = (EditText) findViewById(R.id.edtPass);

        mEditPassConfirm = (EditText) findViewById(R.id.edtPassConfirm);
        mSpinnerDomains = (AutoCompleteTextView) findViewById(R.id.spinnerDomains);

        if (mIsNewAccount)
        {
            mEditPassConfirm.setVisibility(View.VISIBLE);
            mSpinnerDomains.setVisibility(View.VISIBLE);
            mEditUserAccount.setHint(R.string.account_setup_new_username);

            /*
            ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                    android.R.layout.simple_dropdown_item_1line, getResources().getStringArray(R.array.account_domains));
            mSpinnerDomains.setAdapter(adapter);
            */

        }

        //mRememberPass = (CheckBox) findViewById(R.id.rememberPassword);
        //mUseTor = (CheckBox) findViewById(R.id.useTor);


       // mBtnSignIn = (Button) findViewById(R.id.btnSignIn);

//        if (mIsNewAccount)
  //          mBtnSignIn.setText(R.string.btn_create_new_account);

        mBtnAdvanced = (Button) findViewById(R.id.btnAdvanced);

        /**
        mRememberPass.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                updateWidgetState();
            }
        });*/

    }