android-edittext

How to prevent EditText from breaking a line after punctuation

∥☆過路亽.° 提交于 2019-11-27 18:45:26
问题 As default, an Android EditText will break a line if the line is longer than the view, like this: Thisisalineanditisveryverylongs (end of view) othisisanotherline or if the line contains a punctuation character, like this: Thisisalineanditsnotsolong; (several characters from the end of view) butthisisanotherline As a requirement of my work, the text has to break a line only if the line is longer than the view, like this: Thisisalineanditsnotsolong;andt (end of view) hisisanotherline There

Android numeric password field

痴心易碎 提交于 2019-11-27 18:44:27
I have an EditText field which needs to be a numeric password field. Everything works OK in portrait mode; not in landscape. When the user selects the EditText field, the UI zooms into the field and when I type all the characters are visible. I need a numeric keyboard also. I tried setting the input type to text password|number. If I remove "number" option everything works right; otherwise no. Any suggestions? This problem can be solved without using deprecated android:password . Use the following code snippet, but do not reverse the sequence of calls: EditText editText = (EditText)

Clickable links and copy/paste menu in EditView in android

匆匆过客 提交于 2019-11-27 18:42:26
问题 I have an EditText view in my Android app. I need "inner links" in it, this means that I need some buttons or span inside EditText and with onClick to this button I can do some actions (not redirect to web page). I realized this buttons with ClickableSpan() like this linkWord = "my link"; link = new SpannableString(linkWord); cs = new ClickableSpan(){ private String w = linkWord; @Override public void onClick(View widget) { wrd.setText(w); } }; link.setSpan(cs, 0, linkWord.length(), 0); et

Validation on Edit Text

限于喜欢 提交于 2019-11-27 18:36:41
问题 I would like to know how to make a validation on EditText. For example, I have one EditText that should only accept numeric values. If something other than a numeric value is typed by the user then it should show an alert message ( i.e. "please use a numeric value...."). Is there a function available to find out if the entered text is particular type? If possible please include a code snippet. 回答1: Rather than make a pop-up I would integrate a hint into the EditText and I would make it so the

This view is not constrained vertically. At runtime it will jump to the left unless you add a vertical constraint

泪湿孤枕 提交于 2019-11-27 18:26:47
New Layout editor in Android Studio 2.2 keeps showing this error on views like EditText and Buttons. kindly help.Also, any links that help in onboarding with the new constraint layout would be appreciated. code: <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout android:id="@+id/activity_main" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.set.email.MainActivity

In Android, how to create EditText of fixed width?

守給你的承諾、 提交于 2019-11-27 18:19:58
I would like to create an EditText which accepts only numbers, has a maximum of 4 numbers, and is never narrower than it would be if filled with 4 numbers (does not shrink when empty, or have to expand to accommodate 4 numbers, so it's fixed.) The first 2 are accomplished with: android:inputType="number" and android:maxLength="4". How can I set the minimum length? Jean A little hackish , but you can put your EditText inside a FrameLayout alongside with another TextView with text="0000" and visibility=invisible. FrameLayout Should have width=wrap_content and your EditText will have width=match

Android Actionbar Tabs and Keyboard Focus

喜夏-厌秋 提交于 2019-11-27 18:13:45
问题 Problem I have a very simple activity with two tabs, and I'm trying to handle keyboard input in a custom view. This works great... until I swap tabs. Once I swap tabs, I can never get the events to capture again. In another application, opening a Dialog and then closing it, however, would allow my key events to go through. Without doing that I've found no way of getting my key events again. What's the issue here? I can't find any way to get key events once I swap tabs, and am curious what's

Android EditText onClickListener

人盡茶涼 提交于 2019-11-27 17:56:08
i want an EditText which creates a DatePicker when is pressed. So i write the next code: mEditInit = (EditText) findViewById(R.id.date_init); mEditInit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showDialog(DATEINIT_DIALOG); } }); But when i press the EditText the action is the typical: a cursor waiting for typing text instead show the Dialog i want. Any idea? Thanks The keyboard seems to pop up when the EditText gains focus. To prevent this, set focusable to false: <EditText ... android:focusable="false" ... /> This behavior can vary on different

EditText, adjustPan, ScrollView issue in android

纵然是瞬间 提交于 2019-11-27 17:49:32
问题 I have a EditText which is enclosed in ScrollView , but when the keyboard comes up. You can NOT scroll down to the fields that are now covered. I have tried adding adjustSize , adjustPan in the manifest and in the class. But its not working.. 回答1: I was suffering from the same issue and I a found solution. So, maybe it will help you. Please give following attributes to ScrollView tag: android:isScrollContainer="false" And in manifest of your activity to : android:windowSoftInputMode=

Android: EditText in Dialog doesn't pull up soft keyboard

孤街醉人 提交于 2019-11-27 17:46:52
So I've got what seems to be a common problem, which is that the EditText in my dialog box doesn't show up when it gets focus. I've seen several workarounds, such as in this thread , this one and this one (and many more), but I have never seen a satisfactory explanation for why this is happening in the first place. I would much prefer to have android use its own default behavior for EditTexts than to build my own, but it seems like everyone (in those threads) has accepted that the default behavior for EditTexts in Dialogs is to just give a cursor and no keyboard. Why would that be? For the