The DialogFragment has a webview.
Everytime show the DialogFragment,the webview will take some time to load the webview, and before the webpage finished loading, the webview will show the background color. This will affect the user experience. So i want to use some method to preload webview. But really get me there is that m_webviewDialog.show will start two function onCreateDialog and onCreateView. So is there anyway make the webview preload and then add in the onCreateView fucnion?
main activity show code:
public void showWebviewDialog()
{
FragmentManager fragmentManager=getFragmentManager();
if(m_webviewDialog!=null&&m_webviewDialog.isAdded())
{
m_webviewDialog.getDialog().show();
}
else {
m_webviewDialog=mcWebViewDialog.newInstance();
m_webviewDialog.set_loadurl("file:///android_asset/input.html");
m_webviewDialog.show(fragmentManager,"mcWebDialog");
}
}
DialogFragment code:
WebView m_webView;//WebView component
String m_loadurl;
static mcWebViewDialog newInstance()
{
mcWebViewDialog f=new mcWebViewDialog();
return f;
}
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
// other code
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
m_webView = new WebView(getActivity());
//other code
return m_webview;
}