title: Loading a Fragment is taking more time in Android
body: <p>I am trying to replace a fragment in Android and its taking almost 2-3 seconds to load the fragment into the UI. I am not sure what might be causing the issue because I don't do perform heavy threads in the <code>onCreateView</code>. </p>
  
  <p>My fragment that is taking too much time to load has the following in its <code>onCreateView</code>.</p>
  
  <p>Link : <a href="http://pastebin.com/L2497bEZ" rel="noreferrer">Code for my onCreateView</a></p>
  
  <p>All I do in my onCreateView is play around with the visibility of certain layouts depending upon the data from DB. I don't think that it would take me so much time to load the page, it doesn't make sense to me.</p>
  
  <p><strong>What have I tried so far :</strong></p>
  
  <p>I haven't tried anything solid except the following which are some silly implementations of stupidity or I think so..</p>
  
  <ol>
  <li><p>Tried to place a major chunk of code in an Async Task but as most of the code requires <code>setVisibility()</code>, it doesn't work in <code>doInBackground()</code>. And adding a <code>runOnUIThread()</code> is again same as not using a Async Task.</p></li>
  <li><p>I doubted that the fragment manager might be taking some time to load the fragment into UI but when I replaced with another fragment with lesser UI components then it seemed to load fast.I also tried using <code>getFragmentManager().executePendingTransactions();</code>.</p></li>
  </ol>
  
  <p>So thats what I have tried so far but also found out that option 2 is completely unnecessary because the log that I print before the <code>return convertView;</code> is taking 1-2 seconds to print. I am not sure what is going wrong or where its going wrong. Any help will be much appreciated. </p>