0

Is it possible to give focus to a button when the activity starts, while a listView is there on the layout in Android? I tried the following code, but didn't work for me.

button1.requestFocus();

Further I tried

listview.clearFocus();
button1.requestFocus();

Still didn't work.. Can anyone see anything that I am doing wrong or is there a proper way to do it?

Adinia
  • 3,722
  • 5
  • 40
  • 58
JibW
  • 4,538
  • 17
  • 66
  • 101

1 Answers1

1

Have you tried modifying focusableInTouchMode parameter? Similar problem is discussed here: Stop EditText from gaining focus at Activity startup

Community
  • 1
  • 1
peter.bartos
  • 11,855
  • 3
  • 51
  • 62
  • Hi teepee, Yes that was the problem. I added focusableInTouchMode="True" and now its fine. I had previously included focussable="True", Seems like that only not enough. Thank you verymuch...! – JibW Sep 06 '11 at 17:47