我知道这个问题已经被问过了,但是当我这样做时出现错误:
Intent toNextPage = new Intent(this, After_report_page.class);
startActivity(toNextPage);
我该如何解决这个问题(我希望在按钮上单击 xml 布局切换)?
谢谢, 波阿斯
最佳答案
使用 Activity Context 来启动下一个 Activity 而不是 View as:
Intent toNextPage = new Intent(Your_current_Activity.this,
After_report_page.class);
startActivity(toNextPage);
或者您可以使用 view.getContext()
从启动新 Activity 获取上下文:
Intent toNextPage = new Intent(view.getContext(), After_report_page.class);
startActivity(toNextPage);
关于android - 在按钮上单击切换 xml 布局页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14723851/