In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 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: 271
*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.