android - Toasts
2015-12-12 16:52
363 查看
A toast provides simple feedback about an operation in a small popup.
Note: Do not use the public constructor for a Toast unless you are going to define the layout
with
If you do not have a custom layout to use, you must use
LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.custom_toast, (ViewGroup) findViewById(R.id.toast_layout_root)); TextView text = (TextView) layout.findViewById(R.id.text); text.setText("This is a custom toast"); Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.setView(layout); toast.show();
Note: Do not use the public constructor for a Toast unless you are going to define the layout
with
setView(View).
If you do not have a custom layout to use, you must use
makeText(Context, int, int)to create the Toast.
相关文章推荐
- Studio Compile Sdk Version 使用API23: Android6.0创建项目中使用V4包控件问题兼容解决方案
- ViewDragHelper分析
- android camera小结
- Android之Fragment学习(一)
- android内存管理(二)
- Android 自己的自动化测试(2)依据ID查找对象(java)
- Android界面之Activity
- Android的消息处理机制源码分析
- android中如何切换EditText是否可编辑
- Android LinearLayout+ScrollView 模仿ListView效果,是为了使每个Item的EditText无法失去焦点
- Android Apk uninstall install
- android 视图重绘
- Android IntentService
- Android 获取签名公钥 和 公钥私钥加解密
- Android乐动力的开始启动页面开源代码
- Android IntentService的使用与源码解析
- Android Fragment 你应该知道的一切
- Android Studio 教程
- Android Studio错误:failed to complete gradle execution
- Android正在使用Handler实现信息发布机制(一)