android-edittext

Android edittext key return goes to next text

为君一笑 提交于 2019-11-28 17:46:58
I have a series of EditText entries and would like it so when the user hits the enter key it will go to the next Editext. I know how do this one at a time but is there a way to tell all of the edittext controls to use the same function that checks the key entry and advances the cursor. It seems kind of crazy to have one function for each of the EditTexts Much simpler than sniffing keys: try setting android:singleLine="true" and android:imeOptions="actionNext" (at least for single-line entry textviews). Read more in the Android documentation for TextView. Update: singleLine is deprecated now,

Android EditText for password with android:hint

Deadly 提交于 2019-11-28 17:44:48
Just noticed that android:password has been deprecated , and we should be using android:inputType. Was experimenting with it by setting in my xml android:inputType="textPassword" Indeed it behaves like android:password="true" for EditText, but it seems that if I use android:inputType, android:hint will not work. The EditText will be blank. There is no such issues when using android:password with android:hint. Am I missing something here about android:inputType? mango Hint is displayed correctly with android:inputType="textPassword" and android:gravity="center" if you set also android:ellipsize

Hide soft keyboard on application load

半腔热情 提交于 2019-11-28 17:07:36
问题 I have an application with an EditText element on the main view. This means that when my application is loaded the soft keyboard appears per default. I would like to be able to hide the keyboard on load, so it does not show until i tap on the EditText view. How do i manage this? 回答1: You can do something easier. Add this to the LinearLayout (or any other layout that is the root): <LinearLayout ... android:focusable="true" android:focusableInTouchMode="true" ... /> 回答2: In your AndroidManifest

How to Make EditText Box Height Expand

不羁岁月 提交于 2019-11-28 16:47:54
Here is my layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <EditText android:id="@+id/etTweetReview" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:ems="10" android:hint="Discuss up to 140 characters" android:imeOptions="actionDone" android:inputType="textCapSentences" android:lines="2"

Remove focus border of EditText

丶灬走出姿态 提交于 2019-11-28 16:17:20
How can I remove the border with appears when focusing an EditText View? I need it cause this view has little space in the screen, but without the border it's enough. When running on Emulator an orange border appears, on Device a blue one. el-milligano Have you tried setting the background of the EditText to a transparent colour? <EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="@string/hello" android:background="#00000000" /> <EditText android:id="@+id/edittext" android:layout_width="wrap_content" android:layout_height="wrap_content" android

Android 8.0 Oreo crash on focusing TextInputEditText

青春壹個敷衍的年華 提交于 2019-11-28 15:46:04
After updating some of our devices to android 8.0 , upon focusing on a TextInputEditText field inside of a TextInputLayout , the app crashes with this Exception : Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.getBoundsOnScreen(android.graphics.Rect)' on a null object reference at android.app.assist.AssistStructure$WindowNode.(AssistStructure.java) at android.app.assist.AssistStructure.(AssistStructure.java) at android.app.ActivityThread.handleRequestAssistContextExtras(ActivityThread.java:3035) at android.app.ActivityThread$H

How do you set the max number of characters for an EditText in Android?

天大地大妈咪最大 提交于 2019-11-28 15:42:00
问题 How do you set the max number of characters for an Android EditText input? I see setMaxLines, setMaxEMS, but nothing for the number of characters. 回答1: In XML you can add this line to the EditText View where 140 is the maximum number of characters: android:maxLength="140" 回答2: Dynamically: editText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(MAX_NUM) }); Via xml: <EditText android:maxLength="@integer/max_edittext_length" 回答3: You can use a InputFilter, that's the way: EditText

Disable soft keyboard on NumberPicker

无人久伴 提交于 2019-11-28 15:23:55
I'm trying to deactivate the soft keyboard when using a NumberPicker to enter numerical values (for aesthetic reasons). This is my layout-xml-code: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:id="@+id/linearLayout2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_marginBottom="30dp" android:layout_marginTop="30dp" >

If EditText.getText().ToString() == “” dont work; [duplicate]

与世无争的帅哥 提交于 2019-11-28 14:52:02
This question already has an answer here: How do I compare strings in Java? 23 answers Here is my code: if(editText.getText().toString() == ""){ editTextBenefaction.setText("0"); } Why he didn't work? Change it to if(editText.getText().toString().equals("")){ In Java .equals() is used to compare if they have the same value and "==" is used to determine if they reference the same object. An even better way is to use if("".equals(editText.getText().toString())){ because this will protect against a NPE . Java String Docs Do not use == with Strings use equals() if(editText.getText().toString()

Change SeekBar progress based on EditText value

微笑、不失礼 提交于 2019-11-28 14:48:42
I am trying to change the progress of a SeekBar based on the number entered in an EditText but for some reason the EditText value goes to the max and I can't slide the thumb in the SeekBar . What I am looking to achieve: If the value entered in the EditText anywhere between 70 and 190 (including both number) change the progress of the SeekBar to that value. Partial Java code: etOne = (EditText) findViewById(R.id.etSyst); etOne.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { String filtered_str = s.toString(); if (Integer.parseInt(filtered_str) >= 70 &&