java - Android 应用程序 Iframe 网站

标签 java android iframe

我正在尝试为我的广播电台制作 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/

相关文章:

java - Hibernate 和 Spring 3 不保存

java - 自动创建数据库 springboot 和 mysql

java - Firestore 文档引用数组

android - java.lang.Error : signal 11 (SIGSEGV), 代码 1 (SEGV_MAPERR) Unity Spine Android

CSS "overflow:scroll"不适用于 chrome

internet-explorer - IE9、HTML5 : Embedding HTML5 page into page with no doctype

java - 超时时运行多个任务

java - 使用 Spring Boot 加载外部文件属性

android - 如何在 Android 的 CalenderView 中获取选定的日期?

css - 使用模态窗口后 IE8 中的 @font-face 问题