Maybe use something like this?

View myView=findViewById(R.id.myView);
  myView.getViewTreeObserver().addOnGlobalLayoutListener(new 
ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                //At this point the layout is complete and the 
                //dimensions of myView and any child views are known.
            }
        });


[from 
http://stackoverflow.com/questions/8418868/how-to-know-when-an-activity-finishes-a-layout-pass]

Thanks.




On Wednesday, April 17, 2013 1:33:21 PM UTC-5, Filipe wrote:
>
> Hi,
>  
> Does Handler.Post() respects the "Post" sequence?
>  
>  
> A simplifyed version of what I am doing in my Activity is:
>  
> public void onCreate(Bundle savedInstanceState)
> {
>  super.onCreate(savedInstanceState);
>  setContentView(new AbsoluteLayout());
>  new Handler().Post(new Runnable() {
>                 public void run() {
>                  CheckView();
>                 }
>             });
> }
> private void CheckView()
> {
>  int 
> myHeight=getWindow().findViewById(Window.ID_ANDROID_CONTENT).getHeight() ;
> }
>  
> Sometimes in myHeight I get the correct values, and sometimes I don't?
>  
> If I change the Handler.Post to Handler.PostDelayed(...,1000) it allways 
> works, so the problem seems to be that when I use Post() the CheckView() 
> code is executed before the setContentView.
>  
> So how can I guarantee to Post code to be executed at the end of all 
> graphic processing has been done, without PostDelayed() ?
>  
> Thanks
>  
> Filipe Madureira
>  
>  
>  
>
>  
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to