Issue
I am kind of lost here so please give me some help.
I've been working on an app on ICS 4.0.2 for my GNex.
As of yet my app structure is as follows :
DemoActivity extends Activity contains three fragments that show up as tabs : MapFragmentTab extends Fragment SettingsFragmentTab extends Fragment AboutFragmentTab extends Fragment
In the map fragment, I want to have a WebView display Google Maps. This is my MapFragmentTab :
public class MapFragmentTab extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View mainView = (View) inflater.inflate(R.layout.map, container, false);
WebView webView = (WebView) mainView.findViewById(R.id.webview);
webView.setWebViewClient(new MyWebViewClient());
webView.loadUrl("http://maps.google.com");
return mainView;
//return inflater.inflate(R.layout.map, container, false);
}
private class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
}
Right now, it seems to be working, however Google Maps ( although the page frame does load ) won't load. I use Chrome Beta, haven't tried the default browser yet.
I'm really confused when it comes to WebViews, WebViewFragments and Fragments... any help would be appreciated.
Solution
You need to enable JavaScript specifically on WebView, as it is disabled by default. Use something like: webView.getSettings().setJavaScriptEnabled(true);
From: http://developer.android.com/reference/android/webkit/WebSettings.html#setJavaScriptEnabled(boolean) http://developer.android.com/resources/tutorials/views/hello-webview.html
Answered By - Casey Artner
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.