I have a layout which contains some views like this:
<LinearLayout>
<TextView...>
<TextView...>
<ImageView ...>
<EditText...>
<Button...>
</linearLayout>
How can I set the focus (display the keyboard) on my EditText
programmatically?
I've tried this and it works only when I launch my Activity
normally, but when I launch it in a TabHost
, it doesn't work.
txtSearch.setFocusableInTouchMode(true);
txtSearch.setFocusable(true);
txtSearch.requestFocus();
Here is how a kotlin extension for showing and hiding the soft keyboard can be made:
Then you can just do this:
Here is KeyboardHelper Class for hiding and showing keyboard