It's a template for android in material design, i want to add different web view in each tab bar, when i try to add it gives me much syntax errors.
here is the code:
public class SampleFragment extends Fragment {
private static final String ARG_POSITION = "position";
private WebView myWebView;
private String LOG_TAG = "AndroidWebViewActivity";
private int position;
public static SampleFragment newInstance(int position) {
SampleFragment f = new SampleFragment();
Bundle b = new Bundle();
b.putInt(ARG_POSITION, position);
f.setArguments(b);
return f;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
position = getArguments().getInt(ARG_POSITION);
View rootView = inflater.inflate(R.layout.page, container, false);
ProgressBarCircular progressBarCircular = (ProgressBarCircular) rootView.findViewById(R.id.progress);
FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fabButton);
fab.setDrawableIcon(getResources().getDrawable(R.drawable.plus));
switch (position) {
case 0:
myWebView = (WebView) findViewById(R.id.webView);
//enable Javascript
myWebView.getSettings().setJavaScriptEnabled(true);
//loads the WebView completely zoomed out
myWebView.getSettings().setLoadWithOverviewMode(true);
//true makes the Webview have a normal viewport such as a normal desktop browser
//when false the webview will have a viewport constrained to it's own dimensions
myWebView.getSettings().setUseWideViewPort(true);
//override the web client to open all links in the same webview
myWebView.setWebViewClient(new MyWebViewClient());
myWebView.setWebChromeClient(new MyWebChromeClient());
//Injects the supplied Java object into this WebView. The object is injected into the
//JavaScript context of the main frame, using the supplied name. This allows the
//Java object's public methods to be accessed from JavaScript.
myWebView.addJavascriptInterface(new JavaScriptInterface(this), "Android");
//load the home page URL
myWebView.loadUrl("http://demo.mysamplecode.com/Servlets_JSP/pages/androidWebView.jsp");
break;
case 1:
break;
case 2:
break;
case 3:
break;
}
return rootView;
}
}
i thought to put :
myWebView = (WebView) findViewById(R.id.webView);
//enable Javascript
myWebView.getSettings().setJavaScriptEnabled(true);
//loads the WebView completely zoomed out
myWebView.getSettings().setLoadWithOverviewMode(true);
//true makes the Webview have a normal viewport such as a normal desktop browser
//when false the webview will have a viewport constrained to it's own dimensions
myWebView.getSettings().setUseWideViewPort(true);
//override the web client to open all links in the same webview
myWebView.setWebViewClient(new MyWebViewClient());
myWebView.setWebChromeClient(new MyWebChromeClient());
//Injects the supplied Java object into this WebView. The object is injected into the
//JavaScript context of the main frame, using the supplied name. This allows the
//Java object's public methods to be accessed from JavaScript.
myWebView.addJavascriptInterface(new JavaScriptInterface(this), "Android");
//load the home page URL
myWebView.loadUrl("http://demo.mysamplecode.com/Servlets_JSP/pages/androidWebView.jsp");
in each "case" and change the url
but this is the errors that i get:
Error:(33, 10) cannot find symbol method
setArguments(android.os.Bundle) Error:(39, 20) cannot find symbol
method getArguments() Error:(63, 48) cannot find symbol class
MyWebViewClient Error:(64, 50) cannot find symbol class
MyWebChromeClient Error:(69, 54) cannot find symbol class
JavaScriptInterface