gpt4 book ai didi

java - Android StartActivity() 崩溃

转载 作者:行者123 更新时间:2023-12-01 18:47:09 26 4
gpt4 key购买 nike

这是我的代码的基本运行

继承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

最佳答案

Help中,您必须在尝试检索R.id.helpmenu之前调用setContentView

关于java - Android StartActivity() 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17278170/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com