I want to build a native webApplication with Android, when i run the code, my default avd tell me that my application crash…
I follow this tutorial on the Google Android documentation : http://developer.android.com/guide/webapps/webview.html
here is my java android code :
package com.example.mobilewebview;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.webkit.WebView;
//import android.webkit.WebSettings;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.loadUrl("http://www.google.com");
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
Thanks !
Move
To right after:
You were getting an error because findViewById() looks for the view in the currently used layout. As you were setting the layout after you tried to find the View inside it, you were getting an error.