Skip to content

Instantly share code, notes, and snippets.

@ZaeemSattar
Created November 1, 2016 13:06
Show Gist options
  • Save ZaeemSattar/be6cc9edf019c72786c5625038a597b3 to your computer and use it in GitHub Desktop.
Save ZaeemSattar/be6cc9edf019c72786c5625038a597b3 to your computer and use it in GitHub Desktop.
public class Insta extends Fragment {
WebView webView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.activity_my_insta, container,
false);
webView=(WebView)root.findViewById(R.id.webView);
WebSettings webSettings=webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webView.loadUrl("https://instagram.com");
webView.setWebViewClient(new MyWebViewClient());
getActivity().setTitle("Instagram");
return root;
}
private class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
}
}
}
@Nouman16
Copy link

Nouman16 commented Nov 5, 2016

OnAttach method functionality in this code ?? in fragment i used this method to cast my interface variable into the calling activity variable..
just like
public void onAttach(Activity activity) {
myInterfaceVariable = (InterFace) activity;

}

then we can send values to activity from fragments by this
myInterfaceVariable.methodName(myValues);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment