android 一些小知识
来源:互联网 发布:c还是java 编辑:程序博客网 时间:2024/05/17 23:48
1,如何自定义一个toast
public static void showToast(Context context){ LayoutInflater inflater = LayoutInflater.from(context); View toastView = inflater.inflate(R.layout.toast_test_custome, null); Toast toast = new Toast(context); toast.setDuration(3000); toast.setView(toastView); //设置自定义view toast.setGravity(Gravity.CENTER, 0, 0); //控制显示到屏幕中间 toast.show(); //注意:一定要调用才能显示}
2,自定义toast显示时间
static CountDownTimer mCountDownTimer; public static void showToast(final Toast toast, long duration, final OnToastStatus toastStatu) { final long tickTime = 200; mCountDownTimer = new CountDownTimer(duration, tickTime) { @Override public void onTick(long millisUntilFinished) { if(millisUntilFinished <= 200){ showToast("最长可录制一分钟"); }else{ toast.show(); } } @Override public void onFinish() { toast.cancel(); if(toastStatu != null){ toastStatu.toastStop(); } } }.start(); } public interface OnToastStatus{ public void toastStop(); } /** * 停止显示Toast */ public static void stopToast(Toast toast){ if(toast != null){ toast.cancel(); } if(mCountDownTimer != null){ mCountDownTimer.cancel(); } }
阅读全文
0 0
- android 一些小知识
- Android中的一些小知识
- android 的一些小知识
- Android的一些小知识
- Android的一些小知识
- 随记一些android小知识
- android 遇到的一些小知识
- Android一些小知识-不定时更新
- android 堆内存的一些小知识
- 一些关于android屏幕的小知识
- Android strings.xml中的一些小知识
- 一些小知识
- COM一些小知识
- google 一些小知识
- 一些小知识
- 一些小知识
- 一些小知识
- 一些小知识
- 对话陆奇:用产品思维变革百度工程师文化,欣赏腾讯内部赛马机制
- 手把手带你入坑迁移学习(by 当过黑客的CTO大叔)
- Mongo监控
- c结构体
- 关于表单屏蔽浏览器自动记住密码/自动明文提示的解决方案
- android 一些小知识
- RPC入门总结(三)RMI+Zookeeper实现远程调用框架
- hash_map inordered_map map之间的比较
- AndroidStudio使用遇到的问题
- 设计模式最简Demo:策略模式[Strategy Pattern]
- CAD命令操作
- SVN最全使用总结
- Java对象及对象引用变量
- Linux命令(24)——mv命令