Android Toast and notification

Source: Internet
Author: User

1. Toast Usage

Toast can be set: Time, location, custom view

1.1 Most common toast

Toast.maketext (toastactivity.  this, "Carloz short Toast", Toast.length_short). Show ();

1.2 Changing the display location of toast

Toast shorttoast = Toast.maketext (toastactivity.  this, the "Carloz short Toast"//  display position on the screen shorttoast.show ();

1.3 Displaying a custom view

Toast imgtoast = Toast.maketext (toastactivity. This, "Carloz Image Toast", Toast.length_short); ImageView IV=NewImageView (toastactivity. This); Iv.setimageresource (R.drawable.ic_launcher); TextView TV=NewTextView (toastactivity. This); Tv.settext ("Carloz Image Toast"); Tv.setlayoutparams (Newlayoutparams (layoutparams.match_parent, layoutparams.wrap_content)); LinearLayout ll=NewLinearLayout (toastactivity. This); ll.setorientation (linearlayout.vertical); Ll.addview (TV); Ll.addview (iv) ;//Imgtoast.setview (iv);//picture instead of text, if you want to display multiple elements, to customize layout, which contains multiple elementsImgtoast.setview (ll); Imgtoast.show ();

The effect is as follows

2. Notification use

Android Toast and notification

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.