Toast自定义
日期: 2019-04-30 分类: 个人收藏 332次阅读
public class CustomerToast extends Toast {
/**
* Construct an empty Toast object. You must call {@link #setView} before you
* can call {@link #show}.
*
* @param context The context to use. Usually your {@link Application}
* or {@link Activity} object.
*/
private TextView contentTv;
public CustomerToast(Context context) {
super(context);
View view = LayoutInflater.from(context).inflate(R.layout.toast_ll, null);
contentTv = view.findViewById(R.id.content_tv);
setView(view);
}
public static CustomerToast makeToast(String content) {
CustomerToast customerToast = new CustomerToast(MyApplication.getInstance());
customerToast.setDuration(Toast.LENGTH_SHORT);
customerToast.setGravity(Gravity.CENTER, 0, 0);
customerToast.contentTv.setText(content);
return customerToast;
}
}
除特别声明,本站所有文章均为原创,如需转载请以超级链接形式注明出处:SmartCat's Blog
标签:Android
下一篇: docker容器常用操作
精华推荐