I have a dialog fragment which essentially contains just a single web view. I want the dialog to popup only once the web view has completed loading the URL.
This is the onCreateView of my DialogFragment
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.dialog_A, container, false);
webView = (WebView) view.findViewById(R.id.web_view);
webView.clearCache(true);
webView.loadUrl(url);
}
The problem I have is that the web view object is created only after the onCreateView() method is called which will be called only after show() is called; which in turn will cause the dialog to popup.
Is there anyway that I can preload the web view before I popup the dialog?
I wouldn't use a
DialogFragmentbecause of theLifeCycleof the fragment. You want to load theWebViewprior to showing it to the user. Therefore I would use a CustomLayout withvisibility=GONEand then when theWebView(inside the layout) finishes loading, I'll fade in the layout. UseFrameLayoutand put it at the top of the hierarchy.