android-edittext

How do I add text from an EditText field to different TextViews in android studio

一笑奈何 提交于 2021-02-08 11:19:13
问题 I'm relatively new to java and new to android studio, so any explanation would be greatly appreciated. I want to create an app that allows the user to enter someones name and assign them to one of two teams. I am at the point where the user can add one name to each team but I am unsure how to add multiple names to each team. In my XML I have a EditText field to enter the name, two buttons to put them in Team 1 or Team 2 and two TextViews to display all the people in each team. <EditText

Redrawing EditText after changing InputType

假装没事ソ 提交于 2021-02-08 07:57:20
问题 I have made a class that is responsible for monitoring an EditText widget following the Observer pattern. Its sole function is to disable or re-enable auto-correct based on a method call. I am able to successfully achieve this, but the problem is that the new InputType only applies to new text I add to the EditText - old text still retains the red underline to show that it can be auto-corrected. Is there any way I can force the new InputType to apply to the entire EditText block, and not

TimePicker Dialog when pressing EditText

此生再无相见时 提交于 2021-02-07 13:28:25
问题 This question has been asked before, but the answers from back then, doesn't seem to work in Android Studio anymore, or else i'm missing something. I want a timePicker dialog to show up when you press the edit text area, to set the time in the editText. However, for some reason, the normal keyboard simply pops up when pressed. I'm not getting any errors, though it still doesn't seem to work. here is the code: final EditText Edit_Time = (EditText) findViewById(R.id.time_view_edit); Edit_Time

TimePicker Dialog when pressing EditText

回眸只為那壹抹淺笑 提交于 2021-02-07 13:27:14
问题 This question has been asked before, but the answers from back then, doesn't seem to work in Android Studio anymore, or else i'm missing something. I want a timePicker dialog to show up when you press the edit text area, to set the time in the editText. However, for some reason, the normal keyboard simply pops up when pressed. I'm not getting any errors, though it still doesn't seem to work. here is the code: final EditText Edit_Time = (EditText) findViewById(R.id.time_view_edit); Edit_Time

Add gradient in edit text border in android

强颜欢笑 提交于 2021-02-07 10:25:42
问题 I want to add gradient only to the border of my editText , I can add gradient but it takes the entire background . How can I apply gradient only to the border , and the rest should be transparent? 回答1: Add the edittext in a layout Set gradient background color for that layout Set margin 1dp for edittext . Set white background for edittext i think now it's displays like your expectation, thank you 回答2: This one does the trick :) <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android=

How To Validate an EditText to handle numbers only in Android?

醉酒当歌 提交于 2021-02-07 08:18:27
问题 How can I validate a text view in android to handle positive integer numbers? I don't want it to accept any character or signs etc... 回答1: Have you taken a look at the EditText's inputType attribute? You can set a whole bunch of different input types that the EditText should limit the user input to. From the sounds of it, you're probably looking for something like: <EditText .... android:inputType="number" ... /> 回答2: You can use regular expressions. See: http://developer.android.com

Layout duplicating itself on screen rotation

穿精又带淫゛_ 提交于 2021-02-07 05:37:27
问题 I have a layout that has an EditText and a Button. I <include> it in my main layout. I'm having a weird issue with the layout and rotation. It seems to duplicate itself when the device (physical) is rotated, messing up the text and layout. Here it is on first open, after I add some extra garble: DSC_0013 is in the EditText on launch of the fragment. Then, I rotate the phone and add some different garble: And you can see the issue pretty clearly. At first, I thought it was just the EditText

Floating label needs to show inside the textinput layout in android studio

孤街醉人 提交于 2021-02-05 11:28:26
问题 I have set a text input floating button But it shows the floating label outside the input box. How can I show inside the input box in android? <com.google.android.material.textfield.TextInputLayout android:id="@+id/text_input_layout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textColorHint="@color/white_new" app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout" android:hint="@string/label"> <EditText android:id="@+id/et_name" android:layout

Handle EditText key change event with input type TEXT

删除回忆录丶 提交于 2021-01-29 20:21:40
问题 My Use case is to restrict user after he has entered 4 lines in text box. Setting maxLines will not work to stop user. I am surprise that Android is not providing key down/up event when input type is InputType.TYPE_CLASS_TEXT . I am receiving event for all other types. Below is my code. EditText et = new EditText(this); et.setMaxLines(3); et.setSingleLine(false); et.setInputType(InputType.TYPE_CLASS_TEXT); et.setHint("First edit text"); et.setKeyListener(this); // This key listener is also

Validate [Preference] filename from EditText using regex

我们两清 提交于 2021-01-29 14:11:57
问题 [FIRST APP] I am providing users with an option to have multiple profiles using different preference files. The users can name their profiles themselves. I have made a custom dialog box to take filename as input in edittext. A valid filename should contains only [A-Z, a-z, 0-9, _, -]. I am letting the user know about this restriction. Whenever a user enters an invalid character, I want that character to be deleted from edittext and preferably display a toast. After a brief search I believe