我正在尝试为我的广播电台制作 Android 应用程序。我希望当用户打开应用程序时,网站会自动加载。我正在关注这个tutorial 但是当我尝试运行该应用程序时,它显示此错误“不幸的是,Tarab Radio 停止工作” 这是我的activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
&MainActivity.java
package com.jibon.tarabradio;
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.Menu;
import android.webkit.WebView;
public class MainActivity extends Activity {
@SuppressLint("SetJavaScriptEnabled") @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView webview;
webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("http://hoicoimasti.com/radio/");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
任何想法我哪里做错了。提前致谢。
最佳答案
put setContentView(R.layout.activity_main);在你的 onCreate 方法中。
关于java - Android 应用程序 Iframe 网站,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20298731/