-2

我需要在我的 Android 应用程序的 Fragment 上显示 Twitter 列表(Link),但我不知道如何在 Fragment 中包含 MyWebViewClient Activity .. 请帮助。

    public class TwitterFragment extends Fragment {
        private WebView webview;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        View rootView = inflater.inflate(R.layout.fragment_twitter, container, false);
        String url = "https://twitter.com/Almounir/lists/intersante";

        webview = (WebView) rootView.findViewById(R.id.myWebView);
        //next line explained below
        webview.setWebViewClient(new MyWebViewClient(this));
        webview.getSettings().setJavaScriptEnabled(true);
        webview.loadUrl(url);

        public MyWebViewClient() {
            super();
            //start anything you need to
         }

         public void onPageStarted(WebView view, String url, Bitmap favicon) {
            //Do something to the urls, views, etc.
         }
        return rootView;
    }
} 
4

1 回答 1

0

I answered my question with a simple WebView like this :

public class TwitterFragment extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View rootView = inflater.inflate(R.layout.fragment_twitter, container, false);

        WebView wv = (WebView)rootView.findViewById(R.id.WebView);

        String url = "https://www.google.com";
        wv.loadUrl(url);
        wv.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }
        });

        return rootView;
    }
}

ThanK You!!!

于 2014-05-10T17:36:37.890 回答