Default focus on RelativeLayout

by devileper » Sun, 12 Apr 2009 05:10:46 GMT

Sponsored Links
 How can you specify which item gets the default focus on Activity
startup?  Using requestFocus programmatically does not work. On
setContextView the first focusable item listed in the XML is given the
default focus. When using RelativeLayout, the first item listed is not
always the desired item or necessarily on top.

Default focus on RelativeLayout

by Mark Murphy » Sun, 12 Apr 2009 09:01:15 GMT


API samples show requestFocus() working in onCreate(), so I am not
certain where your problem lies.

For example: 

If you cannot figure out the problem, post some sample code illustrating
how you are trying requestFocus(), and perhaps we can see the problem.

Mark Murphy (a Commons Guy)  | 

Android App Developer Training: 


Sponsored Links

Default focus on RelativeLayout

by Ward Willats » Sun, 12 Apr 2009 23:00:29 GMT


I have had good luck with requestFocus() in most cases 
(RelativeLayout or otherwise) I've run into trouble where:

1. The focused item was in a ScrollView and caused the view to scroll 
unexpectedly -- confusing me!

2. The activity had a TabHost on it -- the TabHost seems to always 
steal the focus sometime after onCreate(). I've never figured out a 
way around this.

-- Ward


Other Threads

1. wvga854 avd screen size problem?

Hi, all

  I have a problem with the wvga854 avd screen size.  When my
application running on this avd, it does not use the layout-hdpi-v6,
but uses the layout-mdpi-v6.

  To make it clearer, I add the below code. it prints that the screen
size of the wvga854 avd is 320x569 ! Why?

                Display display = ((WindowManager) getSystemService
                int device_width = display.getWidth();
                int device_height = display.getHeight();
                Log.i("screen", "device width is " + device_width);
                Log.i("screen", "device height is " + device_height);

My develop environment is Mac ox + android 2.0 sdk.

I begin to suffer more and more pain of these problems... does it have
to have so many different kinds of android phones on the world?


2. Who do you consider as the Android mobile Apps developers Guru ?

> Go to 

3. Who do you consider as the Android mobile Apps developers Guru ?

4. CDMA home carrier

5. Memory usage problem - leak?

6. Privacy concerns using Android NETWORK_PROVIDER?

7. Saving service killing without "startForeground"