Android 弹出通知Toast的使用
//官方帮助文档: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的使用的更多相关文章
- Windows Phone 8仿Toast弹出通知。
Wp8后台收到消息可以弹出Toast通知,可是应用在前台跑的时候却好像没有办法弹出Toast通知.而需求上有要求要弹出Toast通知,在这种情况下,就开始考虑是否能够做一个类似Toast的弹出通知呢? ...
- Android弹出Toast工具类总结
Android弹出Toast工具类总结,包括系统自带的,也包括自定义的. public class ToastUtil { public ToastUtil() { } public static T ...
- Android弹出选项框及指示箭头动画选择
Android弹出选项框及指示箭头动画选择 Android原生的Spinner提供了下拉列表选项框,但在一些流行的APP中,原生的Spinner似乎不太受待见,而通常会有下图所示的下拉列表选项框 ...
- android 弹出的软键盘遮挡住EditText文本框的解决方案
1.android 弹出的软键盘遮挡住EditText文本框的解决方案: 把Activit对应的布局文件filename.xml文件里的控件用比重设置布局.(例如:android:layout_wei ...
- Android 弹出输入框
final EditText inputServer = new EditText(SettingActivity.this); AlertDialog.Builder builder = new A ...
- android 弹出框(输入框和选择框)
1.输入框: final EditText inputServer = new EditText(this); inputServer.setFilters(new InputFilter[]{new ...
- 【转】 教你如何创建类似QQ的android弹出菜单
原文地址:http://www.apkbus.com/android-18034-1-1.html 大家可能看到android的自带的系统菜单比较难看,如图: 2011-12-4 23:13 上传 下 ...
- android 弹出菜单
<!-- 定义基础布局LinearLayout --> <LinearLayout xmlns:android="http://schemas.android.com/ap ...
- 常用的android弹出对话框
我们在平时做开发的时候,免不了会用到各种各样的对话框,相信有过其他平台开发经验的朋友都会知道,大部分的平台都只提供了几个最简单的实现,如果我们想实现自己特定需求的对话框,大家可能首先会想到,通过继承等 ...
随机推荐
- Mongo客户端
http://www.linuxidc.com/Linux/2012-07/64233.htm http://www.oschina.net/p/rockmongo http://www.cnblog ...
- delete 多表删除的使用(连表删除)
delete 多表删除的使用 1.从数据表t1中把那些id值在数据表t2里有匹配的记录全删除掉 DELETE t1 FROM t1,t2 WHERE t1.id=t2.id 或 DELETE ...
- Linux 备份工具
Linux 备份工具 GNU 的传统备份工具 GNU tar — http://www.gnu.org/software/tar/ GNU cpio — http://www.gnu.org/so ...
- Table XXX is marked as crashed and should be repaired问题
数据表出错了,查询数据获取不到了. 尝试一 重启mysql service mysqld restart 没用,重启并没有把表修复掉 尝试二 check table vicidial_list;rep ...
- 梦游前端,JavaScript兼容性
前端兼容问题出现的原因 何为操作系统?操作系统(Operating System)是管理和控制计算机硬件与软件资源的计算机程序.是的,任何的应用软件必须在操作系统的支持下运行. 大家会疑问?为什么我要 ...
- 构造函时和this指针
通常this指针在对象构造完毕后才完全生成,而在构造函数执行过程中,对象还没有完全生成,所以this指针也是没有完全生成的,在构造函数中使用this指针会存在问题,应该尽量避免. 构造函数中可以访问对 ...
- HDU 1852 Beijing 2008 数论
题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=1852 这道题和HDU1452类似. 题意:给你一个n.k,让你求2008^n所有因子的和(包括1和本 ...
- 【Android Training UI】创建自定义Views(Lesson 1 - 创建一个View类)
发布在我的网站 http://kesenhoo.github.io/blog/2013/06/30/android-training-ui-creating-custom-views-lesson-1 ...
- 《JavaScript 闯关记》之简介
简介 JavaScript 是面向 Web 的编程语言,绝大多数现代网站都使用了 JavaScript,并且所有的现代 Web 浏览器(电脑,手机,平板)均包含了 JavaScript 解释器. 这使 ...
- RadioButton、CheckBox与ToggleButton
1.RadioButton RadioButton被称作为单选框,通常都是以组的形式出现,可以在一组控件中选择一个. RadioButton的使用首先需要加入<RadioGroup/>,在 ...