Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/187.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Android Studio中打开Android应用程序中的任何网站_Android_Android Activity_Web_Android Applicationinfo - Fatal编程技术网

如何在Android Studio中打开Android应用程序中的任何网站

如何在Android Studio中打开Android应用程序中的任何网站,android,android-activity,web,android-applicationinfo,Android,Android Activity,Web,Android Applicationinfo,我刚刚使用android studio启动了一个新应用程序。。但我需要在我的应用程序中打开一个网页。我尝试使用web view,但没有成功。。。当我打开我的应用程序时,它崩溃了 <WebView android:id="@+id/web_view" android:layout_width="fill_parent" android:layout_height="fill_parent" /> 在我

我刚刚使用android studio启动了一个新应用程序。。但我需要在我的应用程序中打开一个网页。我尝试使用web view,但没有成功。。。当我打开我的应用程序时,它崩溃了

<WebView
    android:id="@+id/web_view"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />
在我包含的清单xml文件中

<uses-permission android:name="android.permission.INTERNET"/>

但我的应用程序还是崩溃了,请帮助我


android#android studio首先调用super方法和setcontentview。只有在设置ContentView之后,才能访问函数
findViewByid
和所有

setContentView(int resLayout)
:从版面资源设置活动内容。这个 资源将膨胀,将所有顶级视图添加到活动中

因此,如果未调用,则不会将任何视图添加到活动中。那么您根本无法访问任何视图

像这样改变它

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_references);


   wb=(WebView)findViewById(R.id.web_view);
    WebSettings webSettings=wb.getSettings();
    webSettings.setJavaScriptEnabled(true);
    wb.loadUrl("https://www.google.co.in");
}

干得好我只是想发表评论,请发布stacktrace;)因为我懒得读完整的代码。@ReneM。是 啊我也希望将此答案作为评论发布,但太长了,所以决定将其作为答案发布。:)
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_references);


   wb=(WebView)findViewById(R.id.web_view);
    WebSettings webSettings=wb.getSettings();
    webSettings.setJavaScriptEnabled(true);
    wb.loadUrl("https://www.google.co.in");
}