Android App Development for Beginners - 32 - Master Detail Flow Example

+2 Obaid Masood · January 4, 2015
Hi All !
am Having Problem With The Master Flow Example , 
The Problem Is that When i Click any Item From The List It Gets Opened In Browser Rather Then WebView That We Used , Any Body Know What have i Done Wrong With My Code ?
Here Is a Picture of The Link That got Open In Browser Instead Of WebView :(/images/forum/upload/2015-01-04/6cf3b1ee7ee61d2db9e2a8f023186e3e.JPG

Post a Reply

Replies

Oldest  Newest  Rating
+2 La Theos · January 11, 2015
 I had this same issue.. I got around this the following way,

made a new class as following,

import android.webkit.WebView;
import android.webkit.WebViewClient;

public class OurWVClient extends WebViewClient {

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        // TODO Auto-generated method stub
        view.loadUrl(url);
        return true;
    }



}


Then, the onCreateView method.......

public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_webpage_detail, container, false);

        // Show the dummy content as text in a TextView.
        if (mItem != null) {
            WebView wv = ((WebView) rootView.findViewById(R.id.webpage_detail));
            wv.setWebViewClient(new OurWVClient());

            wv.getSettings().setJavaScriptEnabled(true);
            wv.getSettings().setLoadWithOverviewMode(true);
            wv.getSettings().setUseWideViewPort(true);
            wv.loadUrl(mItem.link);

        }

        return rootView;
    }


Hope it helps
0 Ashwin Chirag · January 21, 2015
Hello Miraj, 

Thank you for the code.
  • 1

Java / Android Development

103,486 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator