Post: Android Beginner Series Tutorials
06-23-2016, 05:17 AM #1
Mr Smithy x
Former Staff
(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

The following 6 users say thank you to Mr Smithy x for this useful post:

01cedricv2, Dan, Sloth, Jon Snow, Ethen
06-23-2016, 05:24 AM #2
01cedricv2
NGU Elite Lifetime Mermber
Originally posted by Mr
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


Nice work Enzo
09-12-2016, 06:40 PM #3
where can i download this application thats building this ???

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo