Very simple Toast Image example:
Using java Syntax Highlighting
- Toast toast = new Toast(this);
- ImageView view = new ImageView(this);
- view.setImageResource(R.drawable.icon);
- toast.setView(view);
- toast.show();
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
Another one:
Using java Syntax Highlighting
- Toast toast = Toast.makeText(this, "lalalal", Toast.LENGTH_LONG);
- View textView = toast.getView();
- LinearLayout lay = new LinearLayout(this);
- lay.setOrientation(LinearLayout.HORIZONTAL);
- ImageView view = new ImageView(this);
- view.setImageResource(R.drawable.icon);
- lay.addView(view);
- lay.addView(textView);
- toast.setView(lay);
- toast.show();
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
The image is not on the background the text is on, but to achieve that, you'll need to extend the Toast class.
SDK Version compatible: 0.9, 1.0
Thanks to MrSnowFlake for creating and sharing this snippet!
Original Post



