Issue
I'm trying to display a WebView in AlertDialog and it works perfect, but also tried to put a ProgressDialog that says "Loading" as the URL of the WebView is loading.
The problem is that the ProgressDialog does not show but it does show the URL in the WebView charge.
Any help?
Thank you
@Override
protected void onPostExecute(String result) {
//Toast.makeText(context, result.toString(), Toast.LENGTH_LONG).show();
/*nombre.setText("");
dni.setText("");
telefono.setText("");
email.setText("");*/
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
alert.setTitle("Title here");
// Para colocar un loading
pd = ProgressDialog.show(getActivity(), "", "Loading...",true);
//--------------------------
WebView wv = new WebView(getActivity());
wv.loadUrl("http:\\www.google.com");
wv.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
if(pd.isShowing()&&pd!=null)
{
pd.dismiss();
}
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
alert.setView(wv);
alert.setNegativeButton("Close", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
alert.show();
}
Solution
Move the call to ProgressDialog.show()
to after the call to alert.show()
.
...
alert.show();
pd = ProgressDialog.show(getActivity(), "", "Loading...", true);
Answered By - Mike M.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.