开发者

Using Intents to switch between classes

开发者 https://www.devze.com 2023-02-10 15:53 出处:网络
I have a \'home page\' on my app with a button in.I have implemented an onClickListener. I want to change to a different class when clicking the button. (Navigating to another page within the app with

I have a 'home page' on my app with a button in. I have implemented an onClickListener. I want to change to a different class when clicking the button. (Navigating to another page within the app with a differe开发者_如何转开发nt XML file) What am I doing wrong??

Intent myIntent = new Intent(this, menu_two.class);
         startActivity(myIntent);

That is in the code which goes in a switch statement which identifies which button has been pressed. I am not using an XML file, layout hard coded straight from java.

Home I have given you enough information to help

thanks


First, make sure that menu_two is an activity. If you are not using an XML, that shouldn't be a problem. Also, verify that you added menu_two to your AndroidManifest.xml file, where you must register all activities that your app uses.

0

精彩评论

暂无评论...
验证码 换一张
取 消