(adsbygoogle = window.adsbygoogle || []).push({});
This tutorial will be the Entire Beginner Series, This will be all in one because it's extremely basic.
Covered:
- Messing with XML
- Binding Views to the activity
- Understand how to set an activity layout
- Understnd how to initialize a view
- Using the OnClickListener interface for buttons and dialogs
- Creating a Dialog
Drag and drop the button onto the xml layout. Or manually code it in the xml code (Better).
Make sure you give the views an id so we can use them later in the code!
You must login or register to view this content.
Red Arrow: We set the layout of the activity to activity_main.xml
Green Arrow: We initialize the view by finding the id.
You must login or register to view this content.
Now it's time to use the OnClickListener Interface for the Button.
This is how it looks like.
Now when you click on the button, lets do something to the text while we are at it.
You must login or register to view this content.
Lets create a Messagebox too!
With messageboxes there is this class called a AlertDialog.
We will have to use it's Builder subclass to edit upon the dialog.
Take a look at how it's done.
You must login or register to view this content.
Now the 2nd paramater to positiveButton is null, if you want you can implement another OnClickListener when the user clicks OK. Try messing with icon and setNegativeButton