Android keyboard is changing from numeric to alphabet - android

I did the following code in my program:
<RelativeLayout
....>
<EditText
android:id="#+id/EditText"
android:layout_width="150dp"
android:layout_height="37dp"
android:layout_below="#+id/Header"
android:layout_toRightOf="#+id/Button"
android:inputType="number"
android:textSize="14dp" />
</RelativeLayout>
but whenever I tried it on my app, the app will first pop out the numeric keypad, and then a sec later, it will changed to alphabet keypad and the edittext is no longer on focus.
Can anyone help? Thanks!

It sounds like somewhere in your layout or UI code something else is using requestFocus, perhaps another input field that is not of type number.

Related

Done key not showing up on keyboard

I am making an Android app and want the done key to show up on the keyboard when the user is typing into the keyboard.
This is the XML code for the EditText:
<EditText
android:id="#+id/answer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:gravity="center_horizontal"
android:textColor="#ffffff"
android:layout_marginBottom="113dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:imeOptions="actionDone"
/>
I thought that adding the android:imeOptions="actionsDone would have the done button appear, but instead the enter button is there and when it is pressed, a new line is created in the EditText. What is the issue?
You will not get done by adding imeOptions.
Add the below attribute to your EditText:
android:singleLine="true"
This will make your EditText a single line and you will see the Done button if that is the only EditText or last EditText. If there are multiple EditText items, then you will see Next button.

EditText gaining focus but my typing doesn't append

I have an EditText and have a hint. When I tap on the EditText, the keyboard appears, though, as I type neither the hint goes away nor my typing goes into view. It's like my input is going to /dev/null. My EditText is inside a ListView cell, if it helps. Here is my layout:
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:background="#00000000"
android:id="#+id/aboutView"
android:layout_gravity="center_horizontal|bottom"
android:layout_centerHorizontal="true"
android:layout_below="#+id/headerFrame"
android:layout_marginTop="12dp"
android:gravity="center"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:textSize="14dp"
android:layout_marginBottom="12dp"
android:hint="Tell something about yourself..." />
Why can this be?
Found the solution here: EditText in Listview loses focus when pressed on Android 4.x
I don't know the exact reason, but I wasn't the only one suffering from EditText focus problems when inside a ListView. I've added android:windowSoftInputMode="adjustPan" to my activity in manifest file and the problem went away.

Why isn't my softKeyboard coming up automatically in android

Strangely, my soft keyboard is not opening automatically.On SO I have looked they seem to ask on How to hide Keyboard...?
I would like to get the keyboard automatically focues on the Text Box.
Here is what I have on my XML
android:id="#+id/msg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:cursorVisible="true"
android:gravity="left"
android:imeOptions="actionDone"
android:inputType="textMultiLine"
android:maxLength="255"
android:paddingLeft="5dp"
android:scrollbars="vertical"
android:textColor="#000000"
android:textColorHint="#000000"
android:textSize="25sp" />
How to fix this?
You stated "Text box".. If you meant "EditText" than one possibility will be to see if there is any other view that is requesting the focus.
You can also try to add view.requestFocus programatically.
I suppose you need add:
android:textCursorDrawable="#null"
to EditText to see the cursor
Simply add this code <requestFocus /> To the EditText you want to be focused and it will open the keyboard for that field:
<EditText
android:id="#+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword" >
<requestFocus />
</EditText>
Add the following line inside your Activity tag in AndroidManifest.xml,
android:windowSoftInputMode="stateAlwaysVisible"
Developer site says,
"stateAlwaysVisible":The soft keyboard is made visible when the user chooses the activity — that is, when the user affirmatively navigates forward to the activity, rather than backs into it because of leaving another activity.
reference
https://stackoverflow.com/a/1510005/1665507
http://developer.android.com/guide/topics/manifest/activity-element.html
http://blog.vogella.com/2010/10/25/android-windowsoftinputmode/
why you have to open a keyboard on a code. it will automatically get opened if you are on EditText

Why if I enter any data into edittext that data not printed in that editext in android?

I am doing one app here in edittext. I need to enter some data like name but when I enter data into edittext that is not displyed. Same app I run in another system that time it's working well. But in some systems it's not working. What is the problem?
My code:
<EditText android:id="#+id/editText1" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_marginTop="425dp"
android:textSize="25dp" android:layout_marginLeft="290dp" android:ems="11">
<requestFocus />
</EditText>
Your code makes no sense. You had HUGE margin values. Try this:
<EditText
android:id="#+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="18dp">
What theme you are using? Try to change the EditText Color.
chdnm=(EditText)findViewById(R.id.editText1);
chdnm.setTextColor(Color.WHITE);

Strange error of dimensionally on the EditText after disabling the standard Android keyboard

in my app I have disabled the standard Android keyboard for each EditText with
myEditText.setInputType(0);
but now when I use the instruction:
myEditText.setText("string");
the sizes of my EditText does not fit to the size of the text you entered; so the text is not displaying in whole.
How can I fix this?
This is my xml:
<LinearLayout
android:layout_width="305dp"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="DECIMAL:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="25sp"
android:textStyle="bold" android:textColor="#000000"/>
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
>
</LinearLayout>
If you want to disable editText then I recommend to use editText.setEnabled(false). Hiding keyboard is not the right solution until you really need it. But if you have disabled edittext then keyboard will not appear even if you focus on it.
I don't think problem is because of keyboard. One thing I observed in your code is, you are setting ems for editText. I think because of ems, editText size is constant always. Check this link for more information.

Categories

Resources