Reputation: 1750
I got a ListView, populated using BaseAdapter
.
In the listview Item there's a numeric EditText:
...
<EditText
android:id="@+id/edit_quantita"
android:layout_width="50dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:background="@drawable/edit_quantita"
android:gravity="center_vertical|center_horizontal"
android:inputType="number"
android:text="1"
android:textColor="#fff"
tools:ignore="HardcodedText" >
</EditText>
...
When I tap on this EditText the numerical keyboard prompts for an instant, and then it's suddenly overlayed by a regular character keyboard. If I try to write something on this keyboard no text is shown anywhere. Curiously, if I tap again on the Editext it behaves as it should, showing only the working numerical keyboard.
What can i do?
Upvotes: 4
Views: 378
Reputation: 4733
The implementation of EditText
has many flaws when used in the ListView
. Try to add this piece of code in your onCreate()
:
int apiVersion = android.os.Build.VERSION.SDK_INT;
if (apiVersion >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH)
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
else
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Upvotes: 5
Reputation: 36
You can try the following:
Hope it helps debug the problem.
Upvotes: 0