1

I have created a webview but it is not showing when I run the app. Does anyone know why?

Here is my code. This is where I load the webview and add a url:

_webView = (WebView) LayoutInflater.from(getBaseContext()).inflate(R.layout.clubdir, null); _webView.getSettings().setJavaScriptEnabled(true); _webView.getSettings().setBuiltInZoomControls(true); _webView.getSettings().setSupportZoom(true); _webView.setWebViewClient(new WebViewClient()); _webView.loadUrl("http://maps.google.com/maps?q=" + Postcode + "&ui=maps"); adapter = new MergeAdapter(); adapter.addView(ImageView); adapter.addView(header); adapter.addView(fixturesView); adapter.addView(header2); adapter.addView(resultsView); adapter.addView(clubinfo); adapter.addView(ClubInfo); adapter.addView(clubdir); adapter.addView(_webView); adapter.addView(moreinfo); adapter.addView(MoreInfo); setListAdapter(adapter); 

Here is the layout that I am inflating:

<?xml version="1.0" encoding="utf-8"?> <WebView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="150dp"> </WebView> 
4
  • 1
    Have you given the Internet permission? Commented Jul 12, 2012 at 12:15
  • yes i have given internet permission Commented Jul 12, 2012 at 12:16
  • What's your layout clubdir contains only webView or anyother? and also, Try to use yourActivity.this for inflating the WebView instead of getBaseContext() Commented Jul 12, 2012 at 12:19
  • Note the almost duplicate lines with a uppercase change in the argument's name for adapter.addView(clubinfo); and adapter.addView(ClubInfo); as well as adapter.addView(moreinfo); adapter.addView(MoreInfo); Commented Jul 12, 2012 at 12:22

1 Answer 1

4

instead of this try this only simple thing:

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <WebView android:id="@+id/webView" android:layout_width="fill_parent" android:layout_height="150dp"> </WebView> </RelativeLayout> 

In your Activity:

 WebView view=(WebView) findViewById(R.id.webView); view.getSettings().setJavaScriptEnabled(true); view.getSettings().setBuiltInZoomControls(true); view.getSettings().setSupportZoom(true); view.setWebViewClient(new WebViewClient()); view.loadUrl("http://maps.google.com/maps?q=Pizza,texas&ui=maps"); 

that's it.try hope this will help you.if it works than proceed with adding other things

Sign up to request clarification or add additional context in comments.

4 Comments

hi that worked but it shows the entire web page is there a way to just show the map
i just passed the url of home page.whatever u want to see pass url inside it.it will help you.
@LukeBatley Then, you better try the MapView with your needed size with it.
you must have to pass latitude and longitude in url

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.