gpt4 book ai didi

java - 单选按钮更改布局 Activity Android Studio

转载 作者:行者123 更新时间:2023-11-29 02:26:12 25 4
gpt4 key购买 nike

main menu
main menu

difficulty image
difficulty image

您好,我正在开发一款游戏。但是我无法修复我的游戏难度。如何让困难模式按钮运行?我希望当我选中 RadioButton 时,我在主菜单中的任何播放按钮都会更改布局 Activity 。帮助

btnOk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

int selectedid = mMode.getCheckedRadioButtonId();
if(selectedid == R.id.radiohard){
Intent intentMain = new Intent(Settings.this, HardMode.class);
startActivity(intentMain);
Log.i("Content ", " Main layout ");
}
popupWindow.dismiss();
}
});

最佳答案

play.setOnClickListener(new OnClickListener() {
Override
public void onClick(View v) {

if (db.difficultyeasy() == 1) {
Intent intent = new Intent(MainActivity.this, GameActivity.class);
startActivity(intent);

}
else if(db.difficultyhard() == 3){
Intent intent = new Intent(MainActivity.this, HardMode.class);
startActivity(intent);
}
});

关于java - 单选按钮更改布局 Activity Android Studio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52078325/

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