0

layout.xml を作成しました。

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

        <WebView
            android:id="@+id/mwebView"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />

    </LinearLayout>

これは私のアクティビティにあります。私はこのWebビューを解決できないか、フィールドではなく、nullpointerexceptionを取得しています。コードは次のとおりです。

     @Override
            protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);

                setContentView(R.layout.main);
                mWebview=(WebView)findViewById(R.id.mwebView);

                new getContactsTask().execute();

            }
4

2 に答える 2

0

Java コードを変更します。

setContentView(R.layout.layout) //true

それ以外の:

setContentView(R.layout.main);  //false
于 2013-05-03T07:09:36.717 に答える