0

There's a way to know when a fragment is effective drawn (and become visible to user) inside a FragmentActivity? Because i need to get coordinates of some wiews inside fragment, and i need that it is visible before do that

giozh
  • 9,868
  • 30
  • 102
  • 183
  • Perhaps this is what you're looking for? http://stackoverflow.com/questions/10024739/how-to-determine-when-fragment-becomes-visible-in-viewpager – Ben Pearson Feb 13 '14 at 14:37
  • They talk about ViewPager, and i don't have a viewpager ! – giozh Feb 13 '14 at 14:38
  • The ViewPager is moot - you can use the setUserVisibleHint on the fragment. You can then expose that via public method to your activity – Ben Pearson Feb 13 '14 at 14:44

1 Answers1

1

Inside Fragment onCreateView you use following:

View view = ...

view.post(new Runnable() {

    @Override
    public void run() {
         // do stuff
    }
});

return view;

I hope I remembered the syntax all correct from the memory :)

Niko
  • 8,093
  • 5
  • 49
  • 85