自定义吐司

来源:互联网 发布:it行业好学吗 编辑:程序博客网 时间:2024/04/27 17:15
//    自定义吐司    public class MyToast {        public MyToast(Context context, String prompt) {            Toast toast = new Toast(context);            toast.setDuration(Toast.LENGTH_SHORT);            View view = View.inflate(context, R.layout.toast_custom,null);            TextView tvPrompt = (TextView)view.findViewById(R.id.tv_prompt);            //ImageView img = (ImageView) view.findViewById(R.id.img);            tvPrompt.setBackgroundResource(R.mipmap.ic_launcher);            tvPrompt.setText(prompt);            toast.setView(view);            toast.setGravity(Gravity.CENTER, 0, 0);            toast.show();        }    }
1 0
原创粉丝点击