alertdialog android - create alertdialog using dialogfragment



1
610

learn how to create Alert Dialog in Android. this video show you all of the steps involved to create #Alert Dialog in #android studio Hey guys welcome to #Androchunk. In this channel you learn about android tutorials and build android application so make sure you Subscribe. 🔔 Subscribe for more: https://www.youtube.com/channel/UCnRqW8jM_q31ZUOtDT4wVig?sub_confirmation=1 Full source code:- https://github.com/Androchunk/SimpleAlertDialog ---------------------------------------------- Overview : A dialog is a window that appears on top of the display or fills the display, interrupting the flow of activity. Dialogs inform users about a specific task and may contain critical information, require decisions, or involve multiple tasks. For example, you would typically use a dialog to show an alert that requires users to tap a button make a decision, such as OK or Cancel. Use the AlertDialog subclass of the Dialog class to show a standard dialog for an alert. The AlertDialog class allows you to build a variety of dialog designs. An alert dialog can have the following regions 1. Title: A title is optional. Most alerts don't need titles. If you can summarize a decision in a sentence or two by either asking a question (such as, "Discard draft?") or making a statement related to the action buttons (such as, "Click OK to continue"), don't bother with a title. Use a title if the situation is high-risk, such as the potential loss of connectivity or data, and the content area is occupied by a detailed message, a list, or custom layout. 2. Content area: The content area can display a message, a list, or other custom layout. 3. Action buttons: You should use no more than three action buttons in a dialog, and most have only two. ---------------------------------------------- Building the AlertDialog The following creates the dialog object ( myAlertBuilder ) and sets the title (the string resource called alert_title ) and message (the string resource called alert_message ): AlertDialog.Builder myAlertBuilder = new AlertDialog.Builder(getActivity()); myAlertBuilder.setTitle(R.string.alert_title); myAlertBuilder.setMessage(R.string.alert_message); Setting the button actions for the alert dialog Use the setPositiveButton() and setNegativeButton() methods of the AlertDialog.Builder class to set the button actions for the alert dialog. These methods require a title for the button (supplied by a string resource) and the DialogInterface.OnClickListener class that defines the action to take when the user presses the button. You can add only one of each button type to an AlertDialog. For example, you can't have more than one "positive" button. Tip: You can also set a "neutral" button with setNeutralButton(). The neutral button appears between the positive and negative buttons. Use a neutral button, such as "Remind me later", if you want the user to be able to dismiss the dialog and decide later. Displaying the dialog To display the dialog, call its show() method: alertDialog.show(); ---------------------------------------------- Question Of The Day :- Create Custom Alert Dialog Share your Solution: Facebook: https://www.facebook.com/Androchunk Solution: https://youtu.be/HCcbYJw1OZE Share this Question : https://youtu.be/HCcbYJw1OZE ---------------------------------------------- Full source code:- https://github.com/Androchunk/SimpleAlertDialog Learn more about Alert Dialog:- 🔔 Subscribe for more Android tutorials: https://www.youtube.com/channel/UCnRqW8jM_q31ZUOtDT4wVig?sub_confirmation=1 ---------------------------------------------- If you have a topic you want me to make a video about use #Androchunk in the comments. If you have any questions, comments or suggestions about this video scripts please leave them in the comments. Official documentation: AlertDialog: https://developer.android.com/reference/android/app/AlertDialog.html Developer-training.gitbooks: https://google-developer-training.gitbooks.io/android-developer-fundamentals-course-practicals/content/en/Unit%202/41_p_use_keyboards,_input_controls,_alerts,_and_pi.html ---------------------------------------------- Music Credits: Title: Dawn Artist: Sappheiros

Published by: AndroChunk Published at: 5 years ago Category: آموزشی