gpt4 book ai didi

android - 获取错误构造函数 Intent(new View.OnClickListener(){}, Class) 在 android 应用程序代码 : 中未定义

转载 作者:行者123 更新时间:2023-11-30 03:05:13 26 4
gpt4 key购买 nike

import android.app.Activity;

import android.content.Intent;

import android.view.View;

import android.view.View.OnClickListener;

import android.os.Bundle;

import android.widget.Button;

import android.widget.RadioButton;

import android.widget.RadioGroup;

import android.widget.Toast;


public class NumberModeSizeOptionsActivity extends Activity {

private RadioGroup radioGroupId;
private RadioButton radioBoard;
private Button button;

@Override

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.board_option);

addButtonListener();

}


public void addButtonListener() {

radioGroupId = (RadioGroup) findViewById(R.id.radioBoard);
button = (Button) findViewById(R.id.btnStart);

button.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {

// get the selected radio button from the group

int selectedOption = radioGroupId.getCheckedRadioButtonId();


// find the radiobutton by the previously returned id
radioBoard = (RadioButton) findViewById(selectedOption);
startActivity(new Intent(this, NumberBoardActivity.class));
//startActivity(new Intent("org.test.slidingtiles.NumberBoardActivity"));
Toast.makeText(NumberModeSizeOptionsActivity.this, radioBoard.getText(), Toast.LENGTH_SHORT).show();
}

});

}


}

最佳答案

将 startIntent 改成这个

startActivity(new Intent(NumberModeSizeOptionsActivity.this, NumberBoardActivity.class));

关于android - 获取错误构造函数 Intent(new View.OnClickListener(){}, Class<NumberBoardActivity>) 在 android 应用程序代码 : 中未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21922657/

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