Android - EditText not showing any text - android

I seem to have quite a specific problem. I have two tablets, one runs on Android 6.0.1, the other on 5.1.1.
I have an activity and a fragment (the fragment is located on an activity). Each has an EditText element with the following layout:
<EditText
android:id="#+id/etInputForm_1_1"
android:layout_width="250dp"
android:layout_height="30dp"
android:layout_below="#id/tvDescription_1"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:cursorVisible="true"
android:imeOptions="actionNext"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingStart="5dp"
android:textColor="#color/Black"
android:textSize="15sp"/>
The problem is, if I test it on the device with Android 6.0.1, everything seems to be ok, I can input text wherever I want to, however on the device with 5.1.1, the EditText in the fragment always seems to be empty no matter how many letters I type (the EditText in the activity still works fine).
But the logs still show that the text IS there (however we can't see it).
Anyone had similar problem and a solution to this?

I had a similar issue where the edit text hint wouldn't go away (representing text was in the field) and no text would show up when I was typing but my logs showed text was indeed in the field. I also had an issue where my spinners would not show the selected option
I solved it by enabling hardware acceleration for my application. Since it is enabled by default (I believe) I removed this line from my <application></application> section of my manifest file: android:hardwareAccelerated="false"

My issue resolved after removing following line from edit text.
android:textAllCaps="true"

The problem was resolved by using android.app.Fragment instead of android.support.v4.app.Fragment. Seems that the support fragment class is buggy when using on tablets with Android 5.1.1.

Related

Copy/Paste menu items aren't shown on some devices in Android EditText

I have a subclass of Android EditText and it' declared as:
...
android:id="#+id/Main.editor"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left|top"
android:inputType="textMultiLine|textNoSuggestions|textVisiblePassword"
android:imeOptions="flagNoExtractUi"
...
On most devices user are able to do a long click and see a menu with Copy/Paste items:
In emulator:
On device (where it works):
However on some devices it's not shown on long click:
What can be a reason?
I'm thinking about declaring android:longClickable="true" explicitly but i believe it's a default value.
UPDATE: It's reproducible on some Android 9 devices, so it seems to be not that issue: https://issuetracker.google.com/issues/65575880
Android has a default feature to show copy/paste menu
Try with this in your xml android:textIsSelectable.
i.e., android:textIsSelectable="true"

Select text for right gravity, doesn't work in EditText control in HTC devices

I'm developing an Android application in which I have an EditText control.
I've set the gravity to right, in order to type in Persian.
But when I try to select a text (which is in Persian), the select pointers won't appear.
It works almost fine when the gravity is not set. Also it works fine in other devices like Samsung. But it doesn't work on HTC devices (HTC One xl in my case).
This is my EditText xml
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/txtShare"
android:layout_weight="1"
android:enabled="true"
android:inputType="text|textMultiLine"
android:hint="#string/typeHere"
android:gravity="right"/>
Does anyone know how to fix this?
Edit 1
Also the cursor is always at the beginning of the lines, no matter where I tap in the text.
Edit 2
I'm almost sure that if I can solve the problem in Edit 1, the first problem will be solved along with it. Cause wherever I click in text, the cursor would remain in the beginning of the line
Try adding following attribute to your EditText
android:ellipsize="end"
If you are using right-to-left text you should use the textDirection property for correct support. Gravity only aligns text, so text you enter would still be left-to-right.
The cursor selection is handled in the onTouchEvent method.
I don't have any HTC device, so just an idea.
Maybe you can try to find the problem from the onTouchEvent method.

textview doesn't go multiline

Here's my XML layout example of one of my TextViews which show itself correctly in android 4.2 ... I've downgraded a Nexus S to gingerbread 2.3.6 to test out my application and debug it! Right now, each of my TextViews doesn't take any more space than one line, not even wrapping itself at the end of the first line. (On 4.2, the example below was taking 3 lines and was adding "..." at the end if there was some text missing!)
How can I make my textViews compatible with gingerbread? Thank you!
<TextView
android:id="#+id/TV_guideRow_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/TV_guideRow_title"
android:layout_below="#+id/TV_guideRow_title"
android:text="blabla text that could go up to 3 lines"
android:textColor="#3BB9FF"
android:layout_alignParentRight="true"
android:layout_above="#+id/TV_guideRow_more"
android:layout_marginRight="8dp"
android:layout_marginBottom="3dp"
android:ellipsize="end"
android:maxLines="3"/>
You want:
android:inputType="text|textMultiLine"
Also, depending on the parent of that TextView, multiline may not render properly. Try manually setting the height to, say, 100dp and see if that works.
After some more investigation, I've found out that all my related textView problems were related to my custom theme, which was made for android 4.0+ (since Holo was used as the base theme)
I've set the APIs which doesn't have holo to use the "Light" theme and everything is showing up correctly without any further modification.

Android EditText - Text overlay issue

I am seeing a weird bug in my app and I was wondering if someone could help me fix it. I have a simple EditText with some existing Text, if I move the cursor to the top and hit the Enter key it moves the first line down and on top of the second line. I made a video to help with the visual of what I am seeing:
https://www.youtube.com/watch?v=vJfTDjBxdT4&feature=youtube_gdata_player
The phone is a stock Samsung Galaxy Nexus. I have tried to change the InputType to various other things but they all see to have the same issue. Here is the layout:
<EditText
android:id="#+id/editor_text"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_weight="0.72"
android:gravity="top"
android:inputType="textMultiLine|textCapSentences|textAutoCorrect"
android:singleLine="false" >
</EditText>
This is a Jelly Bean issue with Hardware Acceleration here is the Google link:
http://code.google.com/p/android/issues/detail?id=38770
I verified that using the Software layer fixed the issue for me.

EditText printing $ when 4 is pressed

I have an EditText where I only allow the characters $0123456789.
Everything is working well except when I press the number 4 (on virtual or hardware keyboard) it prints a dollar sign ($).
Why is it doing this?
Here is the XML for my EditText:
<EditText
android:id="#+id/amount_text"
style="#style/textbox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#null"
android:cursorVisible="false"
android:digits="$0123456789."
android:gravity="left|center_vertical"
android:hint="#string/amount_hint"
android:inputType="textPhonetic|numberDecimal" />
Secondary question:
mAmountTxt.setKeyListener(DigitsKeyListener.getInstance(false, true));
This achieves what I want (sans $). However, it changes the virtual keyboard to one I don't want. I want the phone keyboard with the big number buttons.
First, I'm 100% sure that it doesn't relate directly to your EditText xml. I have tried your xml in Emu 2.1, Emu 4.0, Emu 4.1 and Real Phone 4.0, and it worked well in each.
Other possible causes:
It might be the emulator - they are sometimes buggy. Can you try to make a new instance of the emulator and test it? Or, try restarting adb?
It might be something programmatic. Do you do any replacing or something like that?
I'm not sure what this does: style="#style/textbox"
Second, to make keyboard layout look like a phone, use this instead of setKeyListener
mAmountTxt.setInputType(InputType.TYPE_CLASS_PHONE);
You wrote:
I want the phone keyboard with the big number buttons.
Set inputType to:
android:inputType="phone"
instead of:
android:inputType="textPhonetic|numberDecimal"

Categories

Resources