自定义Toast
来源:互联网 发布:it狂人类似 编辑:程序博客网 时间:2024/05/29 16:50
布局类:
<RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" xmlns:android="http://schemas.android.com/apk/res/android"> <TextView android:id="@+id/textView1" android:layout_width="300dp" android:layout_centerInParent="true" android:background="@drawable/btn_white_shape_selector" android:layout_height="200dp" android:textColor="@color/black"/></RelativeLayout>样式自定义:
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#FFFFFF" /> <corners android:topLeftRadius="10dp" android:topRightRadius="10dp" android:bottomRightRadius="10dp" android:bottomLeftRadius="10dp"/> <stroke android:width="1dp" android:color="#FFFFFF" /></shape>自定义Toast类:
/** * 自定义Toast工具类 */public class MyToast { public Toast mToast; public MyToast(Context context, CharSequence text, int duration) { View v = LayoutInflater.from(context).inflate(R.layout.eplay_toast, null); TextView textView = (TextView) v.findViewById(R.id.textView1); textView.setText(text); mToast = new Toast(context); mToast.setDuration(duration); mToast.setView(v); } public static MyToast makeText(Context context, CharSequence text, int duration) { return new MyToast(context, text, duration); } public void show() { if (mToast != null) { mToast.show(); } }}Activity中调用:
MyToast.makeText(getApplicationContext(), "反馈成功!", Toast.LENGTH_SHORT).show();
阅读全文
2 0
- 自定义Toast
- 自定义Toast
- 自定义Toast
- 自定义Toast
- 自定义toast
- 自定义toast
- 自定义Toast
- 自定义toast
- 自定义Toast
- 自定义Toast
- 自定义Toast
- Toast自定义
- 自定义Toast
- 自定义Toast
- 自定义Toast
- 自定义Toast
- 自定义toast
- 自定义Toast
- Android Studio apk 打包流程
- PullToRefresh+HorizontalScrollView+DrawerLayout
- STM32F072使用SD卡进行IAP升级
- 【干货分享】大数据计算服务MaxCompute使用教程
- S3C2440 gpio
- 自定义Toast
- Win10 中的文件链接
- Android中的链式调用
- ThinkPHP【系统常量与模板替换】
- 默默前行的livego--基于go语言的rtmp直播服务器
- Docker源码分析(二):Docker Client创建与命令执行
- 注解
- List集合去重复
- Leangoo常用功能简介