美文网首页
Android自定义Toast

Android自定义Toast

作者: def294ec8e5b | 来源:发表于2018-05-09 15:03 被阅读8次

public void show(Context context, String tvString){
View layout = LayoutInflater.from(context).inflate(R.layout.toast_common,null);
TextView text = (TextView) layout.findViewById(R.id.tv_message);
text.setText(tvString);
if(toast==null){
toast = new Toast(MyApplication.getContext());
}
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_SHORT);
toast.setView(layout);
toast.show();
}

相关文章

网友评论

      本文标题:Android自定义Toast

      本文链接:https://www.haomeiwen.com/subject/ioonrftx.html