两种有关Toast实现 的例子(图片&文字)


1、使用图片
查看
打印?
1.Toast toast = new Toast(this);
2.ImageView view = new ImageView(this);
3.view.setImageResource(R.drawable.icon);
4. toast.setView(view);
5. toast.show();
2、使用文字对话框
查看
打印?
01.Toast toast = Toast.makeText(this, “liubey”, Toast.LENGTH_LONG);
02.View textView = toast.getView();
03.LinearLayout lay = new LinearLayout(this);
04.lay.setOrientation(LinearLayout.HORIZONTAL);
05.ImageView view = new ImageView(this);
06.view.setImageResource(R.drawable.icon);
07.lay.addView(view);
08.lay.addView(textView);
09. toast.setView(lay);
10. toast.show();

你可能感兴趣的:(toast)