gpt4 book ai didi

Java/Android 如何将 Activity 调用到方法中?

转载 作者:行者123 更新时间:2023-12-01 07:39:31 24 4
gpt4 key购买 nike

如何在方法中调用单独的 Activity :

例如:

private void startApp() {
Patient_Button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// I want this Button to go to an Detailed_ModeActivity
// This is how i Am doing it right now, but it comes out with an
// error
Intent b = new Intent(this, Detailed_ModeActivity.class);
startActivity(b);
}
});

}

任何帮助将不胜感激。Button 在 onCreate 方法中声明

最佳答案

像这样:

Intent b = new Intent(v.getContext(), Detailed_ModeActivity.class);
startActivity(b);

关于Java/Android 如何将 Activity 调用到方法中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7015595/

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