在android系统加载按钮点击新的一页? [英] Load new page on button click in android?

查看:124
本文介绍了在android系统加载按钮点击新的一页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做Android的游戏。我想要有两个按钮,一个开始游戏,一个以显示主菜单画面如何筛选。

I am making a game in android. I want to make a main menu screen that has two buttons, one to start the game and one to display the how to screen.

我班有两个,但是当我启动我的名字和测试按钮,应用程序崩溃。可能有人请告诉我什么是错我的code?

I have classes for both, but when I launch my name and test the buttons, the application crashes. Could someone please tell me what is wrong with my code?

       public void launch()
       {
            Intent i = new Intent();
            i.setClassName("com.testing.blockinvasion", "com.testing.blockinvasion.game");
            startActivity(i);
       }

       public void howto()
       {
            Intent i = new Intent();
            i.setClassName("com.testing.blockinvasion", "com.testing.blockinvasion.howto");
            startActivity(i);
       }

}

我的按钮都在我的定义main.xml中:

My buttons are defined in my main.xml:

 <Button
     android:layout_height="wrap_content"
     android:layout_width="wrap_content"
     android:text="@string/Start"
     android:onClick="launch" />

编辑:最后我只是删除该项目,并开始另一个,一切似乎现在工作得很好。

I ended up just deleting the project and starting another one and everything seems to work fine now.

推荐答案

您需要正确的方法签名。所以,做这种方式:

You need to correct your method signatures. So do it in this way:

public void launch(View v)

public void howto(View v)

这篇关于在android系统加载按钮点击新的一页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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