Home Programming HOW TO MAKE AN ANDROID APP FOR BEGINNERS

HOW TO MAKE AN ANDROID APP FOR BEGINNERS

190
0

Android development can be a great way to turn your idea into reality or start a promising career as an app developer, and getting started is probably easier than you think. These days Android development is done with a tool called Android studio.

Android studio is a kind of like the Microsoft words of writing Android apps, it helps organize your projects and gives you a user-friendly way to create what you are looking for. This post guide you installing Android studio and then make an app. Worry no more, if you don’t have any experience with Android or even programming in general as long as you will read up to the end of this post we will meet up in achieving this project.

Download Android studio, go to the Android developer website and then click the download button accept the terms and conditions and then download Android studio. Once it’s downloaded follow the steps to install Android studio drag it into the Applications folder and then launch Android studio, since you won’t have any previous settings you can choose do not import settings then click

OK to complete the installation, and you will be presented with the Android studio setup wizard. On the first screen you can just click Next for the install type, pick custom and then click Next you can now pick your UI theme or you keep it as default and you may already have the Android SDK installed on your computer but you’ll need to make sure this is checked as well as the Intel haxon performance box, and since you will be running it on a virtual device you will need to include an Android device as well.

This is just a version of Android that runs on your computer, if you have your own Android device you don’t need to include this but it’s recommended if you’re going to continue doing Android development then you can click Next and you can accept the recommended choice there, and click Next again and then finish. Once you’ve downloaded all the components you might need to type in your password to allow it to install hex am then click finish and now that you are running Android studio, pick start a new Android studio project to get started.  First you will need to specify your application name. Assuming you call it randomizer then for the company domain you would put the web address of your company. Let’s call it greehouse.com though really as long as you’re not publishing the app to the Play Store, this can be whatever you want.

Lastly Android used to be written entirely in Java but recently you have been given the freedom to use Collin which is a big improvement over Java.

Check the include Collin support box and then click Next to continue. Next again and then finish now you’re probably ready to get started but before you get on with the app, you need to know how an Android app comes together.

The first piece of an app is the layout which describes how the app should look and Android layouts are created by combining different types of views, at its most basic a view is just a rectangular area on the screen. But there are views that contain text views that act as buttons and even views for holding other views and by combining all these different types of views we can make pretty much anything.

The other piece of an app is the activity you can think of the activity as the code behind the layout, it’s where you tell your buttons what to do getting back to the code it will looks like you are looking at your activity. It will also looks like you have got an error and it will suggest a solution. So you will click accept the agreement and click next and then finish, and that will looks much better. It will take a second to make your screen a little easier to see and make your font size a bit bigger.

Android apps have two parts, the layout and the activity, right now you are inside the activity and if you look inside create function you will see a line that says set content view your layout dot activity underscore main. This is where your layout gets connected to your activity as you might have guessed, this makes activity main.xml your layout, click on it and see what you have got, and you will click right to hide the side section. You can bring it back by clicking the project pane on the screen, you can create your layout by dragging and dropping views, you can also delete views by selecting them and then click backspace. You can also delete the hello world text view, and then start adding some views of your own.

Constraint layout allows you to position the views inside by using constraints which allows you chain Meuse together, it makes creating a layout super simple. You try using constraints with your button to make it look like it does and mock-ups to align it to the bottom. You can start by selecting the button then click on the bottom, white circle and drag it to the bottom of the screen to make the connection notice that it doesn’t quite make it to the bottom. This is because your constraint contains an 8 pixel you can see the details about a views constraints up on the right and if you want to change the buffer you can type in the box or select a value.

Change your buffer to 24 next you need to Center your button to Center something in a constraint layout you just constrain it to both the left and right sides.

Drag the left side to the left and the right side to the right, also you may have noticed that you have two screens, the left one is showing you how the app will look like and the right one is more of a blueprint view, showing you all the little details behind the app you can toggle between showing the design, just the blueprint or both by using the button up there. So just to make things a little easier to see for this screencast. You may be using the design view but keep in mind if you want to see the blueprint view it’s always there awesome.

Now to make your button stay roll, you just need to update the text attribute over. Delete the button and type roll and make it just a little wider so it’s easier to read, you can zoom it into the last thing you need to do with your button, make it wider to change the width of a view you just update the layout with attribute, and make it take up the full width of its constraints by changing it constraint then to make this match the mock-ups, change the buffer for both the left and right constraints to 96. Now that you have got your button add your selector and Android that type of view is called a seat bar.

To find it click on widgets and then drag out a seek bar discreet then let’s constrain the bottom of the seat bar to the top of your button and the sides to the sides of the screen Update the buffers for those constraints to be 32 for the sides and 24 for the bottom, and finally change the layout width to match constraint and you are good to go.

The next piece we need is a text view that says how many, click on the text tab and drag out a text view then let’s constrain it to the left edge with a buffer of 24 and to the top of the seek bar with a buffer of 16 last but not least, change the text to how many and next grab a horizontal divider from the widgets tab and constrain it to the top of how many with a buffer of 16 for the last step. Drag out one final text view and position it and the middle of the remaining space by adding constraints to each side, one to the left, one to the top, one to the bottom and one to the right then make the text start empty and change the text size to 144 SP.

If text size isn’t visible click the view all attributes scroll down all the way to text size and set, it is 144 SP your layout is all finished but before you get back to the activity you should give your views some better IDs, pivot back to view fewer attributes and change the last text view from text view to two results text view and then click on the button and change its ID from button to role button and click yes. Flip back to main activity and start wiring everything together you have already seen that you connect the activity to the layout with the set content view line, add some space below that and then you need to create variables to represent your views and Katlin.

There are two ways to create a variable Val or VAR. Val is for things that don’t change while VAR is for things that do, for example if you are creating a person’s birthday would be a vowel since it doesn’t change, what has something like what he want for dinner would be a VAR.

Creating a variable for a role button, leave a space after set content view and on the next line type Val role button and set it equal to find view by ID and then inside the two carrots type button and press enter to make sure it gets imported and then inside the parentheses you will put the ID of your button after your ID, your die ID dot roll button, this finds your role button from the layout and assigns it to a new variable named role button.

Do the same thing for a results text view and our seat bar Val results text view equals find view by ID and you can click enter to autocomplete that and inside the angle brackets well need to make one a text view and use the ID your die ID that results text view. For the seek bar Val seek bar and this equals find view by ID and then the angle brackets this time you will put a seek bar make sure to press enter so it imports itself automatically and then for the ID of the seek bar it’s your die ID and it defaulted to seek bar.

Now that you have got access to each of these views the next thing you need to do is to make something happen when you click on a button, add a space and then on the next line type roll button dot set on click listener, and choose the option with the brackets then press enter to give us more space in the brackets inside the brackets, this is where you will specify what should happen when you click on your roll button first you will get a random number based on the value of the seek bar and then you will set that random number as the text of your text view.

So create a new Val named Rand and set it equal to random and press enter to make sure it gets imported then parentheses dot next into and pick the option where you pass in an integer to bound it. This will give you a random integer from within a certain range, type seek bar dot progress to have it generate a random number between 0 and the value of your seek bar then on the next line.

Set results text view dot text equal to R and which is our random integer dot to string since Rand is an integer we need to turn it into a string before adding it to your text view and that’s it now to run the app. Click on the play button up then you should have a virtual device from when you installed earlier if you don’t you should be able to connect an Android phone to your computer with a USB cord and see it choose it as a running target you will pick my virtual device then you will click proceed without instant run, and it should boot up a virtual device and run the app. You have  got the app and if you click roll you get random numbers between 0 1 & 2 and if you put it all the way up at 10 you should get between 0 & 9 though. Ideally you have it go from 1 to 10 instead of 0 to 9 also you might want to make the text a little bigger and it will looks like your divider isn’t quite centered so getting back to the code first to make it show a number from 1 to wherever your progress bar is instead of starting at 0 just add 1 to the number there then to fix the issues with the layout go back to activity main.xml and make the text bigger by clicking on the coming in to text size, and try 24s B and see how that looks a little big you will go back , off to 16 that looks better than for the horizontal divider. If you can click it there you just want to constrain that to the right and to the left and you can check if you got it constrained by looking at the constraints on the right looks if you are still missing that left constraint there you go all right then you can run the app again by clicking on the green play button and if you’d like it to not show this dialog each time you run an app you can check this box down here awesome now if we run the app again it looks much better and we get 1 2 & 3 instead of 0 1 & 2 crate chopped creating the app I know that was probably a lot to take in and you might  be feeling a little bit overwhelmed but don’t worry that’s pretty much everyone’s experience it takes time and a lot of practice to get good at anything and while you may not have a deep understanding of Android you’re off to a pretty good start I’m a teacher at tree house an online school where you learn at your own pace at $25 a month you get access to the beginner Android development track which has on-demand content that includes videos quizzes and code challenges teaching you the ins and outs of Android one step at a time click the link at the top of the description to start your seven day free trial at tree house and get started on the beginner Android development track

(Visited 48 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here