Not able to enter values in EditText - android

I'm a newbie in Android development. Recently I have been facing a problem in the EditTexts(eventhough I havent changed any attributes of EditText) used in my app which I'm currently running in Emulator.
On clicking the EditText it receives focus, but on typing something the focus changes to some other view. But I'm able to enter values if I navigate to EditText using Tab button of the keyboard. This happens to all EditTexts in my application.
Surfed net for getting a solution, but did not find one.Help...
Implementation of one of my EditText:
<EditText
android:id="#+id/edittext_testname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/hintEditText1"/>
Thanks in advance.

Ever tried your app on a physical device?
However, I cannot see anything wrong with your EditText xml. Perhaps there is some java code in your activity catching any events related to that EditText? Or maybe to the other view element you mentioned getting the focus?

I had a similar issue but with a custom style I had defined for my EditText. How I fixed it?
<item name="android:focusable">true</item>
<item name="android:focusableInTouchMode">true</item>
So try applying the "android:focusable" and "android:focusableInTouchMode" properties and see if it makes any difference. They should be applied to the EditText by default but give it a go.
(I would have posted this as a comment but I need more rep)

Related

Show comma instead of dot - Keyboard

Is there a way to get a comma for edittext instead of dot. My Keyboard is german, device is samsung.
looking for solution via XML not extra listeners.
So far i have tried
1.
android:digits="0123456789,"
android:inputType="number"
android:digits="0123456789,"
android:inputType="numberDecimal"
android:inputType="numberDecimal"
nothing seems to work, and I still get dot. I have gone through other similar questions but they suggest managing it by adding listener to edittexts. I have a lot of editText and it will be much additional/unnecessary work. There should be an XML simple solution to this.
Also tried
val input = EditText(requireContext())
input.keyListener = DigitsKeyListener.getInstance("0123456789.,")
EditText input = new EditText(THE_CONTEXT);
input.setKeyListener(DigitsKeyListener.getInstance("0123456789,"));

Difference between <android.support.design.widget.TextInputEditText> and <EditText>

I downloaded a code and the source is written in this format:
<android.support.design.widget.TextInputEditText/>
instead of:
<EditText/>
I tested both of them and i didn't see the difference, so I want to know if there's a difference between these two ways of declaring a widget in Android.
<android.support.design.widget.TextInputEditText/>
Creates a Field with an EditText with more functions like show the placeholder up the edit text when you're typing in.
https://gyazo.com/844d6c0fe8aace1ef671859823d39a58
https://gyazo.com/bf891de7807955e76bf487e3a07a6317
Only difference is: in landscape mode you can see the hint in TextInputEditText1, whereas you can't see in EditText.

Change "Done" button in Android numeric keyboard

I have an EditText in Android configured for the number keyboard, and I would like the keyboard's button to say "next", while mine is saying "done".
How can I change that?
I already tried:
<com.innovattic.font.FontEditText
style="#style/CadastroTextBoxStyle"
android:hint="CEP"
android:id="#+id/etCEP"
android:inputType="number"
android:singleLine="true"
android.imeOptions="actionNext" />
And also this:
etCEP.setImeActionLabel("Next", KeyEvent.KEYCODE_ENTER);
But it still says done.
What else can I do?
Thanks
As can be seen in Specifying the Input Method Type, you do not need to call TextView.setImeActionLabel(CharSequence, int) and you have to instead just provide a android:imeOptions value such as actionSend or actionNext in XML attributes to change the label accordingly.
This is not working for you because you have mistyped : as . in your attributes. Switching those out should fix your issue in no time.

make autocompletetextview look like edittext

I am using an AutoCompleteTextView (RobotoAutoCompleteTextView) instead of an EditText. But I want the look and feel of an EditText: i.e. the underline that shows up at the bottom of an EditText. So how might I do that?
My question is a bit incomplete so let me clarify. In the Eclipse Graphical Layout the AutoCompleteTextView looks exactly like the EditText with the underline. But when I run the app in my Samsung Galaxy S5, the underline is gone. Instead I get an ugly box with some "#22000000" background. (Of course I am guessing at the exact hex of the background). So what I need is for the underline to always shows up no matter what device I am using: real phone, or just the Graphical Layout.
Try this:
<AutoCompleteTextView
...
style="#style/Base.Widget.AppCompat.EditText" />
or this
<EditText
...
style="#style/Base.Widget.AppCompat.AutoCompleteTextView"/>

Custom Position of Hint in Edit Text box.

I was wondering if there was any way that I could get a hint at the bottom of an Edit Text view -- and then the user to start entering text at the top of the box.
As a bonus question, is there any way I can make the hint NOT disappear once the user starts entering text.
You can set the position of the text using the "gravity" attribute (as noted at http://developer.android.com/reference/android/widget/TextView.html#setGravity(int)). So to put the text at the bottom you would have;
android:gravity="bottom"
And to answer your bonus question; No, you can't display the hint when text is entered into the edit text view. Displaying the hint only when the box is empty is the defined behaviour as noted at http://developer.android.com/reference/android/widget/TextView.html#setHint(int)
(and yes, I know the links are for TextView, but EditText derives all of its' text positioning and hint handling functionality from TextView).
Actually THERE IS a way to prevent hint from hiding, and it's a cool one :-)
It gives you the Floating Label look with smooth animation very easily and it's from android itself. No extra libraries and stuff.
Try this:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Touch me and I'll fly!"/>
</android.support.design.widget.TextInputLayout>
You can change the behaviour using other xml tags like android:gravity="start|center|end" and others.
As a BONUS, you can use error messages with it :-) Here's the link to that question: https://stackoverflow.com/a/30953551/6474744
And sorry I do not have enough reputatuion to post images, so help yourself:
http://i0.wp.com/androidlift.info/wp-content/uploads/2015/09/Screenshot_2015-09-28-17-03-561.png
Enjoy :-)
The problem with using both android:gravity and android:hint is that they are inter-linked with regard to cursor position.When you position the hint using gravity and you start entering text, it is entered in the same position as the your hint which is a problem if you want it to start traditionally on the top-left corner.

Categories

Resources