在按钮上单击切换xml布局页面 [英] on button click switch xml layout page

查看:153
本文介绍了在按钮上单击切换xml布局页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道已经问过这个问题,但是这样做时出现错误:

I know that this question was already asked but I get an error when I do this:

Intent toNextPage = new Intent(this, After_report_page.class); startActivity(toNextPage);

Intent toNextPage = new Intent(this, After_report_page.class); startActivity(toNextPage);

如何解决此问题(我希望在按钮上单击以切换xml布局)?

How can I fix this (I want that on button click that xml layout switches)?

谢谢你, 波阿斯

推荐答案

使用活动上下文"而不是查看方式"启动下一个活动":

use Activity Context to start next Activity instead of View as:

Intent toNextPage = new Intent(Your_current_Activity.this,
                                             After_report_page.class); 
startActivity(toNextPage);

,或者您可以使用view.getContext()来从启动新Activity的过程中获取上下文:

or you can use view.getContext() to get context from starting new Activity as:

Intent toNextPage = new Intent(view.getContext(), After_report_page.class); 
startActivity(toNextPage);

这篇关于在按钮上单击切换xml布局页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆