开发者

Cannot get web view to work on Android sdk 1.6

I get a blank screen when I try to fill it with a web view on the android. The program runs with out errors, but i get a blank screen. I'm ussin g sdk 1.6 and running it in the simulator

The code packa开发者_运维技巧ge mikenorman.org;

import android.app.Activity;
import android.view.*;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;

public class cBlog extends Activity {
 @Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.blog);

WebView  mWebView;
mWebView=(WebView) findViewById(R.id.bwebpage);
mWebView.loadUrl("http://www.besttechsolutions.biz");
}

the layout file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<WebView

android:id="@+id/bwebpage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.0"
/>

} } -Ted


Change your linear layout to "fill_parent" instead of "wrap-content"

Also you should add </LinearLayout> to the bottom of the layout file. Your Linear Layout is never closed.


Have you added the permission to your manifest so that you can actually load the remote resources?

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

You should be seeing an error if that's the issue, but sometimes folks miss it in the log.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜