Can't get WebView to work

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Can't get WebView to work

Postby sentient » Fri Mar 27, 2009 3:57 pm

Hi guys

when i try to run the following code i get a white screen....

what am i doing wrong?

am i supposed to fire it off as an intent activity? e.g. new Intent(this, WebViewTest.class)

thanks

AndroidManifest.xml
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"   
  3.      package="com.android.test"
  4.      android:versionCode="1"
  5.      android:versionName="1.0.0">
  6.         <uses-permission android:name="android.permission.INTERNET" /> 
  7. ....
  8.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


main.xml
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <LinearLayout
  2.        android:orientation="vertical"
  3.        android:layout_width="fill_parent"
  4.        android:layout_height="fill_parent">        
  5.         <TabWidget
  6.            android:id="@android:id/tabs"
  7.            android:layout_width="fill_parent"
  8.            android:layout_height="wrap_content" />            
  9.         <FrameLayout
  10.            android:id="@android:id/tabcontent"
  11.            android:layout_width="fill_parent"
  12.            android:layout_height="fill_parent">
  13.             <TextView
  14.                         android:id="@+id/textview"
  15.                         android:layout_width="wrap_content"
  16.                         android:layout_height="fill_parent"
  17.                         android:text="this is a third tab"
  18.                 />      
  19.         </FrameLayout>
  20.         </LinearLayout>
  21.         <WebView
  22.                 android:id="@+id/webview"
  23.                 android:layout_width="fill_parent"
  24.                 android:layout_height="fill_parent"
  25.         />
  26.  
Parsed in 0.003 seconds, using GeSHi 1.0.8.4


WebViewTest.java
Code: Select all
public class WebViewTest extends Activity {
   
   WebView webview;
   
   public WebViewTest(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);      
      
      setContentView(R.layout.main);
      webview = (WebView) findViewById(R.id.webview);
      webview.getSettings().setJavaScriptEnabled(true);
      webview.loadUrl("http://www.google.com/m");
   }   

}
Do or do not, there is no try!
sentient
Freshman
Freshman
 
Posts: 8
Joined: Mon Feb 16, 2009 11:57 am
Location: London

Top

Postby stifry » Tue Mar 31, 2009 8:03 am

It looks like your webview code is correct, but your main.xml looks strange. I believe FrameLayout can only be a root level layout.

http://developer.android.com/reference/ ... ayout.html

Try with just the webview in your main.xml first and see if that works.
Visit Trackaroo.com!
Trackmaster - Motorsports Lap Timer
Dynomaster - Performance Dyno
Image Image
User avatar
stifry
Developer
Developer
 
Posts: 46
Joined: Tue Feb 17, 2009 7:50 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests