In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how android customizes dialogs. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
1. Realize the effect
two。 Define dialog.xml (res/layout/dialog.xml)
3. Set the background of the OK and cancel buttons
In the dialog.xml above, both the confirm and cancel buttons are TextView, so you need to customize the background of the button
Confirm_button_style.xml (all color needs to be customized)
Cancel_button_style.xml
4. Customize the use of dialog
Final AlertDialog dialog = new AlertDialog.Builder (xxxClass.this). Create (); dialog.setCancelable (false); / / Click outside the dialog box without disappearing dialog.show (); Window window = dialog.getWindow (); window.setContentView (R.layout.dialog); / / title TextView title = window.findViewById (R.id.dialog_title); title.setText ("dialog_title"); / / content TextView message = window.findViewById (R.id.dialog_message); message.setText ("dialog_message") / / confirm button LinearLayout confirm = window.findViewById (R.id.dialog_confirm); confirm.setOnClickListener (new View.OnClickListener () {@ Override public void onClick (View v) {/ / xxx}}); / / cancel button LinearLayout cancel = window.findViewById (R.id.dialog_cancel); cancel.setOnClickListener (new View.OnClickListener () {@ Override public void onClick (View v) {/ / xxx}}); Thank you for reading! This is the end of this article on "how to customize the dialog box for android". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
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.