【发布时间】:2012-11-24 12:10:28
【问题描述】:
我的布局中有这个:
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
这在我的活动中:
public class Shop extends Activity {
@Override protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
WebView webview;
webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("http://www.example.co.uk/shop");
}
}
清单中的这个:
<uses-permission android:name="android.permission.INTERNET" />
然而,当我运行应用程序时,我收到一个强制关闭错误,并且日志中有一个空指针。我以前从未使用过 webview,所以不知道我在做什么!
【问题讨论】:
-
请在您的问题中添加 logcat 消息
-
com.example.chobbyblings.Shop.onCreate(Shop.java:15) -error
标签: java android webview nullpointerexception