安卓:从surfaceview回到菜单 [英] Android: from surfaceview back to the menu
问题描述
我想提出一个简单的游戏中,我得出了一组位图的上表面观在画布上..
现在我的主要活动,我有我的地方设计了一个按钮的线性布局。
在这个按钮的onclick我写:
i am making a simple game in which i draw a set of bitmaps on a canvas on surface view.. now in my main activity i have a linear layout where i have designed a button. in the onclick of this button i write:
setContentView(new surfaceviewclass(this));
它工作得很好......它打开surfaceview我玩游戏等。
但我想再次查看我开始从我的意思是,当游戏结束我希望菜单重新出现按钮..
我已经打过电话像虚空
it works fine...it opens the surfaceview i play the game etc.. but i want to re view the button where i started from i mean when the game is over i want the menu to reappear.. i have already tried calling the void like
main.menu();
但应用程序崩溃..
请帮助。
but the app crashes.. please help.
推荐答案
请一个新的活动类和的onCreate写()的方法就可以了。
Make a new activity class and write this in onCreate() method of it
setContentView(new surfaceviewclass(this));
和在previous活动创建一个Intent并在单击按钮时启动这一新的活动。
and in the previous activity create an Intent and start this new activity when button is clicked
e.g ....// onclick method of btn on old activity
{
Intent i=new Intent(OldClass.this, NewClass.class);
startActivity(i);
}
....
这篇关于安卓:从surfaceview回到菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!