android-edittext

String Manipulation insert a character every 4th character [duplicate]

北城以北 提交于 2020-08-10 19:01:12
问题 This question already has answers here : Putting char into a java string for each N characters (11 answers) Closed 4 years ago . In Android if I have an edit text and the user entered 123456789012, how could I get the program to insert a dash every 4th character. ie: 1234-5678-9012 ? I guess you need to say something along the lines of:- a=Characters 1~4, b=Characters 5~8, c=Characters 9-12 , Result = a + "-" + b + "-" + c . But I am unsure of how that would look in Android. Many thanks for

How Do I Search For A Word In A Textview?

我们两清 提交于 2020-08-03 03:46:18
问题 Ok, I have an EditText , A Search Button And A Textview with a large scrollable text. When I enter a word in EditText and press the Search Button , the word gets highlighted .Till this, it all works fine. But what I want is that when I enter a word and press the button , it should highlight the word and also move the camera to that particular word ( I think its called focusing in android), I don't want to scroll every time to find my highlighted word.Say my typed word is at the bottom of the

Is it possible to forbid the first number in a EditText to be “0”

谁说我不能喝 提交于 2020-07-18 12:47:15
问题 Hi I just want to know if it is possible to forbid the first number that the user can enter to be "0". <EditText android:id="@+id/editText1" android:layout_width="50dp" android:layout_height="35dp" android:layout_marginBottom="2dp" android:maxLength="2" android:inputType="number" android:digits="123456789"> <requestFocus /> </EditText> Using this code however prevents the user from entering "0" at all but I want just the first digit not to be "0" 回答1: if you want to avoid the user from

Implement autoSizeTextType in android Edittext

好久不见. 提交于 2020-07-15 05:18:06
问题 Android Oreo buildToolsVersion provides a simplified way to autoresize textsize in AppCompatTextView as follows <android.support.v7.widget.AppCompatTextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="50dp" android:maxWidth="300dp" android:background="@android:color/holo_green_light" app:autoSizeTextType="uniform" app:autoSizeMinTextSize="5sp" app:autoSizeMaxTextSize="50sp" app:autoSizeStepGranularity="4sp" /> Can a similar implementation be applied

Enter key starting a new line in EditText instead of submitting the text (Android)

主宰稳场 提交于 2020-07-08 05:23:48
问题 I have a simple todolist app I'm creating whereby new todo items are added via an EditText View. So I'm trying to have it submit the new item to the list when I press the enter key . For some reason though it just enters a new line instead . I have also noticed that it works fine when I use the enter key via an AVD through eclipse but the problem only occurs when I'm running it through my Nexus 4. Here is my code: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate