home+sleep 键home在哪里里

滴掉ANDROID 的BLOG
用户名:滴掉ANDROID
访问量:823
注册日期:
阅读量:5863
阅读量:12276
阅读量:385622
阅读量:1076813
51CTO推荐博文
& &看电影的时候,想必大家经常会在电影开场的时候看见一段故事梗概的介绍,其中有一种显示的效果是一个字一个字先后顺序出现在屏幕上的,并且每出现一个字,还有一个键盘打字的声音出现。这个在android上面怎么做呢?最近做的一个游戏,用到了这个效果,我是这样做的。首先,重写了一个SurfaceView。在这个SurfaceView里面去显示我的这段故事梗概的文字。那如何去实现按照顺序一个字一个字显示出来呢?Thread 首当其冲想到的就是他了。开一个线程去做这个事情,每显示一个字,就让线程sleep一下,然后再显示一个字,最后直到显示了所有的字。这个时候就释放这个线程。那具体怎么做呢?下面一步一步来:(由于代码太多,我只贴重要的核心代码)第一步: & & & & 重写一个自己的Thread 命名为MyThread。 & & & & MyThread 的run方法实现: & & & & & & & & & & & & & & & & &public void run() { & & & & & & & & & & & & & & & & & & & & & & & & & & & & & while(my_thread_runing){ // 这里my_thread_runing 是一个boolean变量,用 & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & //于控制线程是否运行 & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &if(play_text_all_nums & play_text_nums && holder != null) & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & {//play_text_all_nums &代表所有显示字的数量。play_text_nums &代表 & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &//当前显示的字数 & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & get_the_main_explain_currtext(); //计算出当前显示的那些字 & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & Draw_the_main_explain_text(holder);//显示出这些字 & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & synchronized (this) { & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &try { & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &Thread.sleep(300);
& & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & } catch (InterruptedException e) { & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & e.printStackTrace(); & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &} & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &}
& & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &} & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & else & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &{//否则停止线程 & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &my_thread_runing = & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &first_into = & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &if(my_thread != null) my_thread.interrupt(); & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &} & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &} & & & & & & & & & & & & & & & & & & & & & & }第二步:解释则个函数的实现get_the_main_explain_currtext(); //计算出当前显示的那些字
& & & & & & 首先:由字符串ID取出所有的字(这里这个字符串有一个特点:字与字间有一个空格),然后计算出一个有多少个字play_text_all_nums
& & & & & & &然后:每一次取出需要显示的字装载到一个新的字符串变量里面String str_text_OK。这样就实现了。下面问题来了。当正在一个个显示字的时候,按home按键退出,然后在进入这个应用时候!可能出现一个问题:那就是 &MyThread这个线程跑不起来。因为这一次进入 MyThread根本没有start。当然,这里不是讨论为什么出现这个问题。而是想说home按键。网上有大量的人询问如何屏蔽home按键这个时间。其实google是没有开放home按键事件,也就是这个按钮的事件消息不会上传到APP通知我们的。既然google没有开放,我认为大家还是不要这么去做,毕竟google这么去做事有他的优点的,前不久,我去网上下了一个应用,结果这个应用跑起来非常慢,我按返回按键没有反应,结果是我狂试了所有能按的按键和触摸屏,就是退不出来,唯一的办法就把手机的电池给拿掉,从新开机。在这里我非常希望大家不要去把原本好好的android系统给搞乱了。那你说,我要解决问题怎么办,你又要我不要乱改系统原来的设计。我觉得办法很多,只要你想一定可以搞定的。 看看上面的代码,我还加了这个Boolean变量first_into = 用他也是可以解决问题的!本文出自 “” 博客,请务必保留此出处
了这篇文章
类别:未分类┆阅读(0)┆评论(0)
14:26:13 15:21:45> Home! Sweet home - Sleep@home VR
请选择您要上传的头像图片,完成后关闭此弹框即可。
&&&&您所提交的评论已被保存,登录后即可发表
&&&&您已经选择过了。
应用大小:88.2 MB
类别:游戏
当前版本:1.1
语言:英语
运行环境:需要 iOS 6.0 或更高版本。与 iPhone、iPad 和 iPod touch 兼容。
下载此APP的用户也下载
简介:want to go to your home tired in the night s...
Home! Sweet home - Sleep@home VR应用说明
want to go to your home tired in the night shift?
let's sleep at home in VR********************How to use: or pull the magnet button on the card board VR, when you click on the screen and turns off.And to generate only a click event in other equipment, turn off!*********************When very tired in the night shift, when tired has delayed airplane, but a situation that does not go in the house, whenever you want to rest at home Home! Using the Sweet Home, please relax at home !!!!Move anywhere, anytime directly to visit at any time!Please try to seek sleepOr pull the magnet button on the card board VR, when you click on the screen and turns off.Relax with ~ ~
| | | | | | |
| | | | | | | |
|||||||||||||||
iTunes分类排行榜
||||||||||||||||||
京公网安备98
苹果园为iOS用户提供和下载,最新的、、、等,分享最权威的资讯、、及解决办法,拥有最火爆的,苹果园一家专注解决iOS所求的网站。
15:28:58.217---- 15:28:58.233----15.6

我要回帖

更多关于 home在哪里 的文章

 

随机推荐