In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-19 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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.