//官方帮助文档:http://wear.techbrood.com/guide/topics/ui/notifiers/toasts.html
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" > <Button android:id="@+id/btnShowShort"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="show short"/> <Button android:id="@+id/btnShowLong"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="show long"/> <Button android:id="@+id/btnShowDiy"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="show diy"/> <Button android:id="@+id/btnShowImage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="show image"/>
</LinearLayout>
	private Button btnShowShort;
private Button btnShowLong;
private Button btnShowDiy;
private Button btnShowImage;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); btnShowShort=(Button) findViewById(R.id.btnShowShort);
btnShowShort.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "show short",Toast.LENGTH_SHORT).show();
}
}); btnShowLong=(Button) findViewById(R.id.btnShowLong);
btnShowLong.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "show long",Toast.LENGTH_LONG).show();
}
}); btnShowDiy=(Button) findViewById(R.id.btnShowDiy);
btnShowDiy.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast toast=Toast.makeText(MainActivity.this, "show diy",Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER, 100, 100);
toast.show();
}
}); btnShowImage=(Button) findViewById(R.id.btnShowImage);
btnShowImage.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast toast=Toast.makeText(MainActivity.this, "show long",Toast.LENGTH_LONG);
ImageView image=new ImageView(MainActivity.this);
image.setImageResource(R.drawable.cool);
toast.setView(image);
toast.show();
}
});
}

效果:

Android 弹出通知Toast的使用的更多相关文章

  1. Windows Phone 8仿Toast弹出通知。

    Wp8后台收到消息可以弹出Toast通知,可是应用在前台跑的时候却好像没有办法弹出Toast通知.而需求上有要求要弹出Toast通知,在这种情况下,就开始考虑是否能够做一个类似Toast的弹出通知呢? ...

  2. Android弹出Toast工具类总结

    Android弹出Toast工具类总结,包括系统自带的,也包括自定义的. public class ToastUtil { public ToastUtil() { } public static T ...

  3. Android弹出选项框及指示箭头动画选择

     Android弹出选项框及指示箭头动画选择 Android原生的Spinner提供了下拉列表选项框,但在一些流行的APP中,原生的Spinner似乎不太受待见,而通常会有下图所示的下拉列表选项框 ...

  4. android 弹出的软键盘遮挡住EditText文本框的解决方案

    1.android 弹出的软键盘遮挡住EditText文本框的解决方案: 把Activit对应的布局文件filename.xml文件里的控件用比重设置布局.(例如:android:layout_wei ...

  5. Android 弹出输入框

    final EditText inputServer = new EditText(SettingActivity.this); AlertDialog.Builder builder = new A ...

  6. android 弹出框(输入框和选择框)

    1.输入框: final EditText inputServer = new EditText(this); inputServer.setFilters(new InputFilter[]{new ...

  7. 【转】 教你如何创建类似QQ的android弹出菜单

    原文地址:http://www.apkbus.com/android-18034-1-1.html 大家可能看到android的自带的系统菜单比较难看,如图: 2011-12-4 23:13 上传 下 ...

  8. android 弹出菜单

    <!-- 定义基础布局LinearLayout --> <LinearLayout xmlns:android="http://schemas.android.com/ap ...

  9. 常用的android弹出对话框

    我们在平时做开发的时候,免不了会用到各种各样的对话框,相信有过其他平台开发经验的朋友都会知道,大部分的平台都只提供了几个最简单的实现,如果我们想实现自己特定需求的对话框,大家可能首先会想到,通过继承等 ...

随机推荐

  1. 解析XML【C#】

     1.XML元素XML元素包含一个开标记.元素中的数据.闭标记例如:<book>book name</book>其中book是元素名称  book name是元素数据元素名称区 ...

  2. wafer

    Wafer Dicing:晶圆划片 wafer:晶圆 Wafer bumping:晶圆凸起 300mm wafer line:300mm晶圆线 wafer fabrication:晶圆加工 silic ...

  3. 生成war的jdk版本高于tomcat使用的jdk版本,导致项目不能正常被访问

    记录一个耽误30分钟的一个坑: 生成war的jdk版本高于tomcat使用的jdk版本,导致项目不能正常被访问 报404错误

  4. Erlang语言介绍

    Erlang (/ˈɜrlæŋ/ er-lang) is a general-purpose concurrent, garbage-collected programming language an ...

  5. AIX安装SSH

    AIX 7.1   进入 https://www14.software.ibm.com/webapp/iwm/web/preLogin.do?source=aixbp 先下载需要的openssl,op ...

  6. aliCloud基于RAMService实现跨账户资源访问

    1,aliCloud基于RAM service实现跨账户ECS资源访问Example 主要的资源为Instance,Image,Snapshot,disk,SecurityGroup Action太多 ...

  7. HDU 4122 Alice's mooncake shop

    单调队列,裸的!!坑死了,说好的“All the orders are sorted by the time in increasing order. 呢,我就当成严格上升的序列了,于是就各种错.测试 ...

  8. 济南最新公交线路一览(BRT)

    济南最新公交线路一览(BRT) 济南BRT1路 高速公交线路 黄岗路东5:30-21:30 全福立交桥西5:30-21:30 票价1元,刷卡9折,月票有效 高速公交公司 去程:黄岗路东(BRT) - ...

  9. 数字温湿度传感器DHT11--操作源代码

    //IO定义 #define P_DataIN_DHT11 PB0_IN #define P_DataOUT_DHT11 PB0_OUT //宏定义 #define BSET_DHT11 P_Data ...

  10. Linux下命令行显示当前全路径方法

    /etc/profile 和 ~/.bashrc 或者直接在用户的.bash_profile中添加 export PS1='[\u@\h \W]\$' 然后执行source命令