Im trying to load a webview with the code below. Im getting red squiggly lines under the id in R.id.webview. Any idea what I need to do to fix this. The two solutions recommended are to create field and create constant. But, neither one worked…
Thanks for the help.
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class GreatRacksActivity extends Activity {
/** Called when the activity is first created. */
WebView mWebView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("http://mysite.com");
mWebView.setWebViewClient(new HelloWebViewClient());
}
private class HelloWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}}
}
you need to have a webview in your main.xml layout.