自定义Toast

来源:互联网 发布:盐城大数据产业园招聘 编辑:程序博客网 时间:2024/04/29 05:49
public class CustomToast extends Toast {


private TextView textView;
private String text;
private View view;
private int time;
private Context context;

public CustomToast(Context context,String text,int time) {
super(context);
this.context = context;
this.text = text;
this.time = time;
init();
}

private void init() {
view = View.inflate(context, R.layout.custom_toast, null);
setView(view);
textView = (TextView) view.findViewById(R.id.textView);
textView.setText(text);
setGravity(Gravity.CENTER_HORIZONTAL, 0, 0); 
setDuration(time); 
}


}
0 0
原创粉丝点击