DialogFragment with a WebView
import android.content.DialogInterface;import android.net.Uri;import android.os.Bundle;import android.support.v4.app.DialogFragment;import android.util.Log;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.webkit.WebChromeClient;import android.webkit.WebView;import android.webkit.WebViewClient;import android.widget.Toast;import com.adobe.mobile_playpanel.R;public class MyDialogFragment extends DialogFragment { public static MyDialogFragment newInstance() { return new MyDialogFragment(); } WebView wv=null; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){ View v=inflater.inflate(R.layout.fragment_login, container,false); wv=(WebView)v.findViewById(R.id.frag_webView); initWebView(wv); wv.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { // super.onProgressChanged(view, newProgress); getActivity().setProgress(newProgress*1000); } }); return v; } public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); wv.loadUrl("http://google.com"); } private void initWebView(WebView wv) { wv.getSettings().setJavaScriptEnabled(true); wv.clearCache(true); wv.setScrollBarStyle(0); wv.setWebViewClient(new MyWebViewClient()); } private class MyWebViewClient extends WebViewClient { public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { // super.onReceivedError(view, errorCode, description, failingUrl); Log.e("MyWebViewClient", failingUrl); }; @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { Log.d("MyWebViewClient",url); return super.shouldOverrideUrlLoading(view, url); } } public void onDismiss (DialogInterface dialog) { wv.stopLoading(); Log.e("MyDialogFragment", "onDismiss"); //super.onDismiss(dialog); } }
You must Sign up as a member of Effecthub to view the content.
ChOw
2013-09-03
A PHP Error was encountered
Severity: Notice
Message: Undefined index: HTTP_ACCEPT_LANGUAGE
Filename: helpers/time_helper.php
Line Number: 22
Latest Posts
- Android: CookieManager removeAllCookie() Crash
- XlistView: A listview which can pull to refresh and load more (1)
- Millions of Android Phones Could Be Affected by the Heartbleed Bug. Check to See if Yours Is One of Them
- TOP 10 ANDROID GAMES FOR MARCH 2014
- Android:Button with different textcolor and background in different states
8344 views 6 comments
You must Sign up as a member of Effecthub to join the conversation.