笔记7 Toast 常用属性及自定义

来源:互联网 发布:mac怎么设置默认输入法 编辑:程序博客网 时间:2024/05/29 03:52


/** * 自定义toast */public void showDiyToast(){    LayoutInflater inflater = LayoutInflater.from(this);    View toast_view = inflater.inflate(R.layout.activity_main,null);//R.layout.activity_main自定义的布局    Toast toast = new Toast(this);    toast.setView(toast_view);    toast.show();}/** * 带图片的toast */public void imgToast(){    Toast toast = Toast.makeText(this,"带图片的",Toast.LENGTH_LONG);    LinearLayout toast_layout = (LinearLayout) toast.getView();    ImageView iv = new ImageView(this);    iv.setImageResource(R.mipmap.ic_launcher);    toast_layout.addView(iv);    toast.show();}

0 0
原创粉丝点击