The Tomast of Android development

Source: Internet
Author: User

For the first time in the blog Park to publish the article, I just figured out about the Android development of the prompt settings, share to everyone.

Tomast is often used in Android, a method used for simple user hints, after groping I found the tomast of the two ways to use, first of all, share a bit, but also look at the master advice.

The first system defaults to the way:

Toast.maketext (Getapplicationcontext (), "System comes with hint form", toast.length_short). Show ();

The second way of customizing:

Toast toast = new Toast (Getapplicationcontext ());
Toast.setgravity (gravity.center_vertical, 0, 0);//Setting the location of the display
Toast.setduration (Toast.length_long);//Set the displayed time

Toast.setview (Getlayoutinflater (). Inflate (R.layout.activity_two,null));//Set a custom view

Toast.show ();

Views displayed in the customization:

<linearlayout
Android:id= "@+id/linearlayout1"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:orientation= "Horizontal"
>
<imageview
android:background= "@drawable/fire_eye_alien"

Android:layout_width= "50dip"
android:layout_height= "50dip"
/>
<textview
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Android:layout_gravity= "Center_vertical"
android:text= "Custom Form Hints"
Android:textsize= "20dip"
/>
</LinearLayout>

Personal feeling for the tomast of the custom type, the difficulty lies in the introduction of the view, hoping that the great God can give more guidance.

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.