启动画面功能
不久前,我为我的相当基本的游戏应用程序制作了一个启动屏幕。它持续 5 秒,我按照教程进行操作。
我想做的是让启动屏幕持续 20 秒,除非屏幕被点击,我想充当“跳过”功能来跳过启动屏幕,但允许用户根据需要阅读无聊的内容。
我当前的代码是:
public class StartScreen extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.startscreen);
Handler x = new Handler();
x.postDelayed(new StartScreenHandler(), 5000);
}
class StartScreenHandler implements Runnable {
public void run() {
startActivity(new Intent(getApplication(), Menu.class));
};
I've made a splash screen for my pretty basic game app a while ago. It lasts for 5 seconds and I followed a tutorial for it.
What I want to do is make the splash screen last for 20 seconds, UNLESS the screen is tapped which I want to act as a 'skip' feature to skip the splash screen but allow the user to read the boring bits if they so wish.
My current code is:
public class StartScreen extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.startscreen);
Handler x = new Handler();
x.postDelayed(new StartScreenHandler(), 5000);
}
class StartScreenHandler implements Runnable {
public void run() {
startActivity(new Intent(getApplication(), Menu.class));
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为此,您必须使用 GestureDetectors。并且您必须相应地处理 onTouch 事件或 singleTap 事件内的事件。看这里的例子。
http://android-journey.blogspot.com/2010/01/android -gestures.html
For this you have to make use of GestureDetectors. And you have to handle your event inside the onTouch event or singleTap event accordingly. Look here for an example.
http://android-journey.blogspot.com/2010/01/android-gestures.html
我不确定这个,只是猜测,尝试一下是否有效。
我想您一定在启动屏幕上有一些图像,只需在图像的 onClick 事件上结束启动屏幕活动并调用下一个事件即可。
试试这个并让我知道
I am not sure about this, just guessing, try if it works.
I suppose you must be having some image on the splash screen, just end the splash screen activity on the image's onClick event and call the next event.
Try this and let me know