In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces examples of toast tips in android. The article is very detailed and has certain reference value. Interested friends must read it!
Toast prompt is a message box type in Android system, a simple message prompt box, is a mechanism used to display prompt information in Android; the idea of Toast class is to be as inconspicuous as possible, while still displaying information to the user.
Toast tips in android
Toast prompt is a message box type in Android system, a simple message prompt box; it is a mechanism used to display prompt information in Android.
When the view is displayed to the user, it appears floating in the application. Unlike Dialog, it never gains focus and cannot be clicked on. The user will probably be typing something else in the middle.
The idea behind Toast is to be as unobtrusive as possible, while also presenting information to users that they want them to see. And Toast display time is limited, Toast will automatically disappear according to the display time set by the user.
Here's an example of how to use Toast:
Default Style: Toast.makeText (getApplicationContext(), "Default Toast Style",Toast.LENGTH_SHORT).show(); Custom Display Position: toast = Toast.makeText (getApplicationContext(),"Custom Location Toast", Toast.LENGTH_LONG);toast.setGravity (Gravity.CENTER, 0, 0);toast.show(); with picture effects: toast = Toast.makeText (getApplicationContext(),"Toast with pictures", Toast.LENGTH_LONG);toast.setGravity (Gravity.CENTER, 0, 0);LinearLayout toastView =(LinearLayout) toast.getView();ImageView imageCodeProject = new ImageView (getApplicationContext());imageCodeProject.setImageResource (R.drawable.icon);toastView.addView (imageCodeProject, 0);toast.show(); fully customized: LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate (R.layout.custom,(ViewGroup) findViewById (R.id.llToast));ImageView image =(ImageView) layout.findViewById (R.id.tvImageToast);image.setImageResource (R.drawable.icon);TextView title =(TextView) layout.findViewById (R.id.tvTitleToast);title.setText ("Attention");TextView text =(TextView) layout.findViewById(R.id.tvTextToast);text.setText("Fully Custom Toast");toast = new Toast(getApplicationContext());toast.setGravity(Gravity.RIGHT| Gravity.TOP, 12, 40);toast.setDuration(Toast.LENGTH_LONG);toast.setView(layout); toast. show (); The above is "Example of toast prompt in android" All the contents of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.