webview部分有错误。请帮帮我。按照此处的教程,我设置了一个应用程序,该应用程序应该能够打开 URL 并将其放入 WebView 中。唯一的问题是应用程序在模拟器中运行时停止。
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import info.androidhive.materialdesign.R;
`enter code here`public class WebViewActivity1 extends AppCompatActivity {
WebView wv1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_view1);
wv1=(WebView)findViewById(R.id.webView);
WebSettings webSettings = wv1.getSettings();
webSettings.setJavaScriptEnabled(true);
wv1.loadUrl("http://www.medplusmart.com/");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_web_view_activity1, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
最佳答案
首先 - 在您的问题中,请向开发人员提供您的 logCat。
第二 - 你的代码中有错误,看看这张图片,为什么会有“在此处输入你的代码”
之前 公共(public)类WebViewActivity1扩展AppCompatActivity
希望对你有帮助:)
关于javascript - 无法加载网页查看Android Studios,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38131346/