I have a numeric EditText
in a fragment
that shows the keyboard as normal when I select the EditText
. I want to hide the keyboard when I enter OK. So I use a hide_keyboard() function which is working fine.
The issue I have is when I re-select the EditText
, then the soft keyboard doesn't show up anymore. I tried many things but none worked.
Any ideas?
Here is my EditText:
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="7"
android:id="@+id/kip_time"
android:hint="Reflexion time"
android:layout_below="@+id/chronometer_kipling"
android:layout_alignStart="@+id/chronometer_kipling"
android:layout_marginTop="10dp"
/>
and my hide_keyboard() function:
private void hide_keyboard(Context context, View view) {
InputMethodManager inputManager = (InputMethodManager)
context.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.toggleSoftInput(0, 0);
}
and finally my onclicklistener method:
kip_time.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
reflexion_time = Integer.parseInt(kip_time.getText().toString());
reflexion_time = reflexion_time * 1000;
hide_keyboard(context, view);
}
});