android-edittext

Show the password with EditText

安稳与你 提交于 2019-12-03 02:42:40
问题 I use an EditText to enter password. And a CheckBox to show password or not. Below function is the part: public void ShowPassword() { if (cb.isChecked()) { password.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); } else { password.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); } } When it checked, it show password. But when it not checked, it does show stars. How to modify it to show star while the cb is not checked? 回答1: I don't know exactly the specifics, but this code

How do I prevent an EditText from resizing itself when the user is typing?

≡放荡痞女 提交于 2019-12-03 02:10:22
问题 I have an EditText and a Button set next to each other on the same horizontal line. It looks great, except when the user enters a lot of text, the EditText is resized, and the Button is squished. I have both EditText and Button set to layout_width="wrap_content" . "fill_parent" messes up the layout, and I don't want to use absolute sizes if I don't have to - the way it is now looks great in both landscape and portrait, I just don't want the EditText to resize. My layout: <TableLayout android

How can I do something, 0.5 second after text changed in my EditText?

痴心易碎 提交于 2019-12-03 01:49:03
问题 I am filtering my list using an EditText. I want to filter the list 0.5 second after user has finished typing in EditText . I used the afterTextChanged event of TextWatcher for this purpose. But this event rises for each character changes in EditText. What should I do? 回答1: editText.addTextChangedListener( new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count,

Soft keyboard covers an EditText in a PopupWindow

时光怂恿深爱的人放手 提交于 2019-12-03 01:47:02
I've thrown together a simple test project that displays a PopupWindow containing an EditText (on Android 2.2). When I tap the EditText, the soft keyboard is shown, as I would expect. However, the soft keyboard covers the EditText, and I cannot get the screen to pan to keep the EditText in view in the way I would have thought it should. My code: TestAdjustPanActivity.java: package com.example; import android.app.Activity; import android.graphics.drawable.BitmapDrawable; import android.os.Bundle; import android.view.Gravity; import android.widget.PopupWindow; public class TestAdjustPanActivity

Custom EditText is not showing keyboard on focus

馋奶兔 提交于 2019-12-03 01:34:33
I am creating a custom EditText class because i need to set some custom fonts; However now when i click on the editText the android keyboard does not pop up anymore... here is my class: package ro.gebs.captoom.utils.fonts; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Rect; import android.graphics.Typeface; import android.util.AttributeSet; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import ro.gebs.captoom.R; public class CustomFontEditText extends EditText { private Context context; public

Android disable space only for Edittext

自闭症网瘾萝莉.ら 提交于 2019-12-03 01:23:56
In my android application I need to disABLE Spacebar only. But I didn't find a solution for this problem. I need to disable space bar and when user enter space should not work, special characters, letters, digits and all other should work. What I tried is, etPass.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub String str = s.toString(); if(str.length() > 0 && str.contains(" ")) { etPass.setError("Space is not allowed"); etPass.setText(""); } } @Override public void

margin inside the edit text in android

元气小坏坏 提交于 2019-12-03 00:56:46
My question is : I have an EditText and I want set a margin inside the EditText, I mean margin for the content (the text) of the edit text, not a margin for a the view witch I can resolve by this attribute : android:layout_marginLeft . I need let some space before and after the text inside the EditText. I tried to set the padding, but doesn't work ! this is my xml code : <FrameLayout android:layout_width="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_marginLeft="2dp"> <EditText android:inputType="none" android

android edittext remove focus after clicking a button

 ̄綄美尐妖づ 提交于 2019-12-03 00:13:32
I have an Activity with an EditText and a Button. When the User clicks on the EditText, the keyboard is shown and he can type in some Text - fine. But when the user clicks on the Button I want the EditText to be no more in focus i.e. the keyboard hides til the user clicks again on the EditText. What can I do to 'hide the focus' of the EditText, after the Button is clicked. Some Code I can add in the OnClick Method of the Button to do that? EDIT: <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <EditText android:id="@+id

How to hide Android Soft Keyboard? [duplicate]

天涯浪子 提交于 2019-12-02 23:52:02
问题 This question already has answers here : How to set visibility Android Soft Keyboard (97 answers) Closed 5 years ago . I have two EditText Views and a Button in Linearlayout. After Completion of writing in the edittext, I want to hide the Android Virtual keyboard, How can I do that? 回答1: You may use the InputMethodManager class like this: InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow( yourEditText.getWindowToken()

Better way to get all the text in an EditText from an InputConnection?

我是研究僧i 提交于 2019-12-02 23:42:28
I've written an IME (InputMethodService) and I need to get all the text from the EditText it is editing. I know one way: InputConnection inputConnection = getCurrentInputConnection(); inputConnection.append(inputConnection.getTextBeforeCursor(9999, 0)) .append(inputConnection.getTextAfterCursor(9999, 0)); It works, but it seems pretty stupid and clunky. However there is no such method InputConnection.getText() . Is there a better way? P.S. I cannot access the EditText from my IME because it belongs to the parent app so please don't tell me to use EditText.getText(), unless you know a way to