android - Fragment starts loading on the second click and is null on the first click -


i hosting fragment in main activity , i'm refreshing fragment using updateuifragment() in asynctask. on selecting fragment mainactivity, fragment should refresh, trigger updateuifragment() method , display contents.

the issue is, fragment null on first click , on second click, fragment starts updating , displays contents. once data loads after second click, fragment works on next clicks.

@override public void onresume() {   super.onresume();   updateuifragment(); }  // ensures fragment updates when invisible @override public void onhiddenchanged(boolean hidden) {   super.onhiddenchanged(hidden);   if (!hidden) {      updateuifragment();   } } 

this in mainactivity,

private final datafragment datafragment = new datafragment(); 

why fragment showing data on second click , not on first click?
tried using isadded() didn't work.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -