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弹出对话框
我们在平时做开发的时候,免不了会用到各种各样的对话框,相信有过其他平台开发经验的朋友都会知道,大部分的平台都只提供了几个最简单的实现,如果我们想实现自己特定需求的对话框,大家可能首先会想到,通过继承等 ...
随机推荐
- MySQL应用层传输协议分析
001.在MySQL应用层传输协议中主要有如下三种类型的数据: 01.整数类型. 02.字符串类型. 03.描述数据包. 002.MySQL应用层传输协议中对整型的说明: 01.固定长度的整型---- ...
- STM32F10xxx启动模式分析(详细)
STM32的启动模式: STM32有三种启动模式,对应的存储介质均是芯片内置的: 1. User Flash Memory(Main Memory) = 芯片内置的Flash,用户程序存放 ...
- 做为一个Java程序员,你需要哪些傍身的技能?
最近总有些断断续续的思考,想想从我入行以来,我到底学会了什么,做成过什么,以后要做什么,如何提升自己······· 工作3年了,常听人说3年,5年,10年是程序员的坎,每过一个都会有新的想法,新的改变 ...
- Android 自定义PopupWindow动画效果
public class RollActivity extends Activity { private View view; private Button btn; private PopupWin ...
- cf466B Wonder Room
B. Wonder Room time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- windows Oracle DBases auto backUp
- IKAnalyzer使用停用词词典进行分词
@Test // 測试分词的效果,以及停用词典是否起作用 public void test() throws IOException { String text = "老爹我们都爱您.&qu ...
- BPM7.5.1升级细节,万事开头难
背景:Linux5.9,BPM 7.5.0集群环境,内置WAS ND7.0.0.17 详情见上图 故障现象:升级BPM 7.5.1集群环境 1,按照 IBM 信息中心步骤,升级BPM需下载相应补丁 包 ...
- About Quick Packaging and Custom Packaging
About Quick Packaging and Custom Packaging The Enterprise Manager Support Workbench provides two met ...
- gcc 编译和链接
1.现在对两个文件生成可执行文件 //thanks.c #include <stdio.h> int main(void) { printf("Hello World\n&quo ...