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();
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…