I am trying to create an android application that just consists of a web view. I gave an example from the Android developer site and modified it. But as simple as it seems, every call to findViewById results in a null pointer. .Java file:
public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); WebView webView = (WebView) findViewById(R.id.webview);
Layout File:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:orientation="horizontal" tools:context=".MainActivity" > <WebView android:id="@+id/webview" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </LinearLayout>
And I put the following line in the manifest:
<uses-permission android:name="android.permission.INTERNET" />
I am puzzled ...
source share