How to Developed an Android App for Beginners :Ideas For Development..


  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 kind of like the Microsoft words of writing Android apps it helps organize our projects and gives us a user-friendly way to create what we're looking for in this video we'll walk through installing Android studio and then make an app don't worry if you don't have any experience with Android or even programming in general as long as you follow along we'll all end up at the same place now we'll download Android studio in just a second but first let's look at what we'll be making these days there are too many choices of everything so to help us choose between a bunch of options we'll make an app that lets us specify how many options there are and then selects one at random when we click a button awesome now that we know where we'd like to end up let's start by downloading Android studio click the link below to 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 these 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 now we're presented with the Android studio setup wizard on this first screen we can just click Next for the install type let's pick custom and then click Next now we can pick our UI theme I'll keep it as default and then when we're selecting our SDK components I already have the Android SDK installed on my computer but you'll want to make sure this is checked as well as the Intel haxon performance box and since I'll be running this on a virtual device we'll want to include an Android device as well this is just a version of Android that runs on our 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 let's click Next and we can accept the recommended choice here 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 hexam then let's click finish and now that we're running Android studio let's pick start a new Android studio project to get started first we'll need to specify our application name let's call it randomizer then for the company domain you would put the web address of your company so for me this will be teamtreehouse.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 we've been given the freedom to use Collin which I think is a big improvement over Java let's check the include Collin support box and then click Next to continue Next again and then finish now I know you're probably ready to get started but before we get on with the app let's take a minute to talk about 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 looks like we're looking at our activity it also looks like we've got an error and it's suggesting a solution so I'll click that accept the agreement and click Next and then finish that looks much better now I'll take a second to just make my screen a little easier to see and make my font size just a bit bigger okay so Android apps have two parts the layout and the activity and right now we are inside the activity and if we look inside this on create function we can see a line that says set content view our layout dot activity underscore main this is where our layout gets connected to our activity as you might have guessed this makes activity main.xml our layout let's click on it and see what we've got and I'll click right here to hide this side section we can bring it back by clicking the project pane on this screen we can create our layout by dragging and dropping views we can also delete views by selecting them and then hitting backspace let's get rid of this hello world text view and then start adding some views of our own so click it and backspace the views are up here on the top left so if we drag out a button we'll get a button now one thing to call out is that we're putting these view inside of another view called a constraint layout what's cool about a constraint layout is that it lets us position the views inside by using constraints which let us chain Meuse together it makes creating a layout super simple let's try using constraint with our button to make it look like it does and mock-ups to align it to the bottom 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 our constraint contains an 8 Pixel you can see the details about a views constraints up here on the right and if you want to change the buffer you can type in the box or select a value let's change our buffer to 24 next we need to Center our button to Center something in a constraint layout you just constraint  it to both the left and right sides so let's drag the left side to the left and the right side to the right also you may have noticed that we have two screens here the left one is showing us what the app will look like and the right one is more of a blueprint view showing us all the little details behind the app you can toggle between showing the design just the blueprint or both by using this button up here so just to make things a little easier to see for this screencast I'll 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 our button say roll we just need to update the text attribute over here on the right so we'll delete button and type roll and let me make this just a little wider so it's easier to read we can zoom this into the last thing we need to do with our button is make it wider to change the width of a view you just update the layout with attribute let's make it take up the full width of its constraints by changing this to match constraint then to make this match the mock-ups let's change the buffer for both the left and right constraints to 96 now that we've got our button let's add our 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 our button and the sides to the sides of the screen let's also update the buffers for those constraints to be 32 for the sides and 24 for the Bottom finally let's change the layout width to match constraint and we're good to go the next piece we need is a text view that says how many let's 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 let's change the text to how many next let's 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 let's 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 top one to the top one to the bottom and one to the right then let's make the text start empty and change the text size to 144 SP if text size isn't visible over here on the right click the view all attributes scroll down all the way to text size and set it is 144 SP all right our layout is all finished but before we get back to the activity we should give our views some better IDs let's pivot back to view fewer attributes and change this last text view from text view to two results text view and then let's click on the button and change its ID from button to role button and click yes okay let's flip back to main activity and start wiring everything together we've already seen that we connect the activity to the layout with this set content view line let's add some space below that and then we need to create variables to represent our views and Kotlin there's two ways to create a variable Val or VAR val is for things that don't change and VAR is for things that do for example if we were creating a person their birthday would be a vowel since it doesn't change what has something like what they want for dinner would be a VAR let's start by creating a variable for a role button let's 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 these two carrots let's type button and hit enter to make sure it gets imported and then inside the parentheses we'll put the ID of our button after our that ID so our die ID dot roll button this finds our role button from the layout and assigns it to a new variable named role button now let's do the same thing for a results Text view and our seat bar val results Text view equals find view by ID and we can hit enter to autocomplete that and inside the angle brackets well need to make this one a text view and use the ID our die ID that results text view then for the seek bar Val seek bar and this equals find view by ID and then the angle brackets this time we'll put a seek bar make sure to hit enter so it imports itself automatically and then for the ID of the seek bar it's our die ID and it defaulted to seek bar now that we've got access to each of these views the next thing we need to do is make something happen when we click on a button let's add a space and then on the next line let's type roll button dot set onclick listener and choose the option with the brackets then hit enter to give us more space in the brackets inside these brackets is where we'll specify what should happen when we click on our roll button first we'll get a random number based on the value of the seek bar and then we'll set that random number as the text of our text view so let's create a new Val named Rand and set it equal to random and hit enter to make sure it gets imported then parentheses dot next int and pick this option where we pass in an integer to bound it this will give us a random integer from within a certain range let's type seek bar dot progress to have it generate a random number between 0 and the value of our seek bar then on the next line let's 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 our text view and that's it now to run the app let's click on this play button up Here then you should have a virtual device from when we 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 up here to choose it as a running target I'll pick my virtual device then we'll click proceed without instant run and it should boot up a virtual device and run the app and there we go we've got the app and if we click roll we get random numbers between 0 1 & 2 and if we put it all the way up at 10 we should get between 0 & 9 though ideally we'd have it go from 1 to 10 instead of 0 to 9 also we might want to make this text a little bigger and it looks like our divider isn't quite centered so getting back to the code first to make it show a number from 1 to wherever our progress bar is instead of starting at 0 well just add 1 to this number right here then to fix the issues with the layout go back to activity main.xml and let's make the text bigger by clicking on this coming in to text size and let's try 24s B let's see how that looks that looks a little big we'll back that off to 16 that looks better then for the horizontal divider if I can click it there we go we'll just want to constrain that to the right and to the left and we can check if we got it constrained by looking at the constraints up here on the right looks like we're still missing that left constraint there we go all right then we 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 treehouse 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 treehouse and get started on the beginner Android development tra

Comments

  1. Harrah's Reno Casino & Hotel - Mapyro
    Find Harrah's Reno 전라북도 출장안마 Casino & Hotel 창원 출장마사지 locations, rates, amenities: 양산 출장샵 expert Reno research, only 삼척 출장샵 at Hotel and Travel Index. 수원 출장마사지 Realtime driving directions to Harrah's Reno

    ReplyDelete

Post a Comment

Popular posts from this blog

The Ultimate Camera King is G cam (Google Camera Mode)..

Shortcut Keys of computer: 15 Amazing Shortcuts You Aren't Using,