Please explain me the issue about soft keyboard.
For example, I have an EditText on my activity or dialogfragment or fragmentactivity, whatever.
here it is:
<EditText
android:id="@+id/edPswrd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword" >
<requestFocus />
</EditText>
When it shows for the first time I do not see the soft keyboard and have to press editText for it to receive focus and the keyboard appears. Another activities are different, when it appears on screen the keyboard are loaded without any help.
I thought that
< requestFocus />
means that EditText will be focused and keyboard will appear, but I am wrong.
How should I manage what component will receive focus and keyboard will automatically appear.
I think it’s a bug or a feature which tries to present the whole activity to you without obscuring it with the soft keyboard at first. I’ve searched once for information regarding that but unfortunately found nothing coming from a really reliable source.
Anyway, to show the soft keyboard you can do this:
I’ve also seen this code that should force the soft keyboard to become visible just after activity start, but never tried it:
And if you want to hide soft keyboard you can do this:
Edit:
For a
DialogFragmentthis should work: in theonCreateView()method do this: