Android StartActivity()崩溃

时间:2013-06-24 14:38:20

标签: java android android-intent android-activity

所以继承了我的代码

Heres MainActivity.java:

package com.ngn;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity {

private Button button;

public void onCreate(Bundle savedInstanceState) {
    final Context context = this;

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

    button = (Button) findViewById(R.id.helpbutton);

    button.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                Intent intent = new Intent ("com.ngn.HELP"); MainActivity.this.startActivity(intent);
            }

        });

}

}

这是我的help.java

package com.ngn;

import android.os.Bundle;
import android.app.Activity;
import android.webkit.WebView;
import android.webkit.*;


public class Help extends Activity
{

private WebView webView;
@Override 
public void onCreate (Bundle savedInstanceState){
// superoncreate now
super.onCreate(savedInstanceState);

webView = (WebView) findViewById(R.id.helpmenu);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("file:///android_asset/main.html");
webView.setWebViewClient(new WebViewClient()
    {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
            }

});;}} 

每次我点击编辑时的帮助按钮冻结我使用AIDE With Premium for android

1 个答案:

答案 0 :(得分:4)

Help

您必须在尝试检索setContentView之前致电R.id.helpmenu