tags:

views:

58

answers:

2

Hi All

As known, when using the setContentView() method, a view can be displayed on screen. My question is whether there is a way to receive an event when the view is actually displayed on screen (since it takes some time for the view actually being displayed after the setContentView() method has been called).

Thanks.

A: 

I'd look into View.onAttachedToWindow or perhaps View.onLayout. Also possibly Window.Callback.onAttachedToWindow. I haven't done research on this though, to see what the precise order of events is.

By the way, what is the use case for this?

Roman Nurik
A: 

I want to open device's keyboard for a certain EditText when the LinearLayout which contains the EditText is being displayed. I tried to use requestFocus() and than to open the keyboard using the InputMethodManager, but nothing happen (the EditText only being focused but the keyboard doesn't open). I guess this happens since when trying to open the keyboard for the EditText, the EditText itself is still displayed on screen. If I set a timer with a timer task to open the keyboard 1 seconds after the LinearLayout is disaplyed using the setContentView() method, it works.

I'll try using the methods you wrote, thank you.

WhiteTigerK
You may want to delete this answer (since it's just a comment) and add it as a 'comment' to my answer above.See the FAQ for more info: http://stackoverflow.com/faq
Roman Nurik