//官方帮助文档: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. mysql tee 命令

    tee 命令说明: 用过mysql的应该都会知道mysql有一个叫show 的命令,这个命令应该是SQL标准之外的一个扩展:和这个类似mysql还扩展了一个叫tee的命令. tee的功能是把你的所有输 ...

  2. SQL Server 索引整理与堆重组。

    重新组织索引: alter index idx_OrderID      on dbo.OrderDetail      reorganize | reorganize;---可以rebuild 也可 ...

  3. 2014第8周三杂记及web标准学习

    昨天遇到一个问题,安卓中mp3默认打开方式的设置,本来如果直接用播放器来查找文件打开没问题,但不知为何播放器只能在历史文件夹中查找,那么在ES文件管理器中找到对应mp3文件后却总是被默认的ES播放器打 ...

  4. 【二叉树->链表】二叉树结构转双向线性链表结构(先序遍历)

    二叉树存储结构属于非线性链表结构,转化成线性链表结构,能简化操作和理解.然而由非线性转线性需要对整个树遍历一次,不同的遍历方式转化结果页不一样.下面以先序为例. 方法一: 递归法.递归遍历二叉树,因为 ...

  5. linux之SQL语句简明教程---TRIM

    SQL 中的 TRIM 函数是用来移除掉一个字串中的字头或字尾.最常见的用途是移除字首或字尾的空白.这个函数在不同的资料库中有不同的名称: MySQL: TRIM( ), RTRIM( ), LTRI ...

  6. Java List 汉字进行排序

    Comparator<Person> cmp = new Comparator<Person>() { public int compare(Person o1, Person ...

  7. android gallery的使用

    1: xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     xml ...

  8. javascript模式——Facade

    Facade模式为许多代码提供一个方便的接口,不现实代码实现的复杂性,这样,使用者只需要关心他的使用接口就可以使用. 下面来看一段Facade模式的运用,绑定事件在浏览器之间是不一样的,利用Facad ...

  9. Mschart应用之曲线图表spline

    本文主要是Mschart应用之曲线图表spline,实现6个模拟数据的图表,其中数据源X轴为当前系统时间,Y轴是由随机函数产生的不同范围的随机数. 首先是自定义一个数据表,然后产生的数据添加到该数据表 ...

  10. xcode新建项目介绍

    xcode新建项目介绍 1.打开xcode选择“create a new xcode project 2.product name 工程名称 campany identifter 公司id 一般都写公 ...