I'm facing a strange problem with my code. This is my layout:
<RelativeLayout
android:id="@+id/container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<EditText
android:id="@+id/editText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:background="@android:color/transparent"
android:digits="0123456789,."
android:gravity="center"
android:imeOptions="actionDone"
android:inputType="numberDecimal"
android:selectAllOnFocus="true"
android:textSize="@dimen/sp15" />
</RelativeLayout>
And this is code for opening keyboard:
container.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(editText.hasFocus()) {
editText.clearFocus();
}
editText.requestFocus();
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(currentStake, InputMethodManager.SHOW_IMPLICIT);
}
});
Now on most devices, when i tap on container, text inside edittext is all selected, numeric keyboard appear and i can type numbers (for example 15,20, etc). On Huawei devices the behavior is different. In fact when user tap on container text inside edittext is all selected, numeric keyboard appear, but every time i type a digit, text continue keep selected, so i'm not able to type numbers > 9. For example if i type 20, when i press 2, on edittext 2 appear (but selected), and when i press 0, this replace 2 so i have a 0 inside edittext and not 20. I'm going crazy to find a solution, how can i do?