当前位置:操作系统 > 安卓/Android >>

Android ApiDemos示例解析(28):App->Notification->NotifyWithText

除了使用Notification之外,Toast也可以用来通知用户某件事发生了,Toast为一个透明的对话框,可以在屏幕上显示几秒钟后自动消失。功能上有点类似Tooltip。 Toast的一个特点时不会获取屏幕焦点(Focus)从而不会影响应用的运行。

NotifyWithText介绍了使用Toast的基本方法,Toast在屏幕上显示的时间间隔是可以控制的。Show Short Notification 和Show Long Notification就设置里两个不同的时间间隔。一个显示较短的信息,一个显示较长的信息。

 

[java] 
Toast.makeText(NotifyWithText.this, R.string.short_notification_text, 
 Toast.LENGTH_SHORT).show(); 
  
Toast.makeText(NotifyWithText.this, R.string.long_notification_text, 
 Toast.LENGTH_LONG).show(); 
Toast.makeText(NotifyWithText.this, R.string.short_notification_text,
 Toast.LENGTH_SHORT).show();
 
Toast.makeText(NotifyWithText.this, R.string.long_notification_text,
 Toast.LENGTH_LONG).show();

\

 作者:mapdigit
 
 


补充:移动开发 , Android ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,