【问题标题】:"Unfortunately, has stopped" eclipse android avd“不幸的是,已停止” eclipse android avd
【发布时间】:2014-02-27 12:40:12
【问题描述】:

在 eclipse/android AVD 中,我得到“不幸的是,已停止”

请帮忙..这是代码 我只是按照其他代码...

我尽我所能我只是不知道 怎么办...

help help help...不是一个完整的程序员...

package com.somedomain.animatedinteractive;
import android.annotation.SuppressLint;
import android.app.Activity;    
import android.graphics.Color;        
import android.os.Bundle;
import android.webkit.WebSettings.PluginState;
import android.webkit.WebView;

public class MainActivity extends Activity {    
    WebView mWebView;    
    /** Called when the activity is first created. */    

    @SuppressLint("SetJavaScriptEnabled")
    @SuppressWarnings("deprecation" )
    @Override    
    public void onCreate(Bundle savedInstanceState) {    
        super.onCreate(savedInstanceState);   
        setContentView(R.layout.main);

        mWebView = (WebView) findViewById(R.id.action_settings);            
        mWebView.getSettings().setJavaScriptEnabled(true);           
        mWebView.getSettings().setPluginState(PluginState.ON);            
        mWebView.loadUrl("file:///android_asset/Parable_Book.swf");             
        mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);     
        mWebView.setBackgroundColor(Color.parseColor("#000000"));
    }

}

main.xml

<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />

【问题讨论】:

    标签: android eclipse apk


    【解决方案1】:

    您的 main 布局没有 ID 为 action_settingsWebView。改变

    mWebView = (WebView) findViewById(R.id.action_settings);
    

    mWebView = (WebView) findViewById(R.id.webview);
    

    此外,当收到“不幸的应用程序已停止”消息时,最好查看 logcat 中的异常堆栈跟踪。也将其包含在您的问题中。

    【讨论】:

    【解决方案2】:
    package com.somedomain.animatedinteractive;
    import android.annotation.SuppressLint;
    import android.app.Activity;
    
    import android.graphics.Color;
    
    
    import android.os.Bundle;
        import android.webkit.WebSettings.PluginState;
    import android.webkit.WebView;
    
    public class MainActivity extends Activity {
    
        WebView mWebView;
    
        /** Called when the activity is first created. */
    
    
        @SuppressLint("SetJavaScriptEnabled")
        @SuppressWarnings("deprecation" )
        @Override
    
        public void onCreate(Bundle savedInstanceState) {
    
            super.onCreate(savedInstanceState);
    
            setContentView(R.layout.main);
    
    
    
            mWebView = (WebView) findViewById(R.id.webview);
    
            mWebView.getSettings().setJavaScriptEnabled(true);
    
            mWebView.getSettings().setPluginState(PluginState.ON);
    
            mWebView.loadUrl("file:///android_asset/Parable_Book.swf"); 
    
            mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); 
    
            mWebView.setBackgroundColor(Color.parseColor("#000000"));
        }
    
    }
    
    main.xml
    
    <?xml version="1.0" encoding="utf-8"?>
    <WebView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/webview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />
    

    【讨论】:

    • 向 OP 解释您更改的内容以及原因通常是个好主意,而不仅仅是发布代码,否则他们不会从中学到任何东西
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-03
    • 1970-01-01
    • 2014-08-28
    • 1970-01-01
    • 2015-06-10
    • 2016-12-12
    • 2013-12-11
    相关资源
    最近更新 更多