Skip to main content

How to Create an Android App With Android Studio


Step 1: Install Android Studio

Install Android Studio
Installer.jpg
  1. Go to http://developer.android.com/sdk/index.html to download Android Studio.
  2. Use the installer to install Android Studio following its instructions.

Step 2: Open a New Project

Open a New Project
ApplicationName.jpg
TargetDevices.jpg
AddActivity.jpg
CustomizeActivity.jpg

  1. Open Android Studio.
  2. Under the "Quick Start" menu, select "Start a new Android Studio project."
  3. On the "Create New Project" window that opens, name your project "HelloWorld".
  4. If you choose to, set the company name as desired*.
  5. Note where the project file location is and change it if desired.
  6. Click "Next."
  7. Make sure on that "Phone and Tablet" is the only box that is checked.
  8. If you are planning to test the app on your phone, make sure the minimum SDK is below your phone's operating system level.
  9. Click "Next."
  10. Select "Blank Activity."
  11. Click "Next."
  12. Leave all of the Activity name fields as they are.
  13. Click "Finish."
*Note: It is typical naming convention in Android projects to set the company name as some form of "example.name.here.com".

Step 3: Edit the Welcome Message in the Main Activity

Edit the Welcome Message in the Main Activity
WelcomeMessage.jpg
  1. Navigate to the activity_main.xml tab if it is not already open.
  2. Make sure that the Design tab is open on the activity_main.xml display.
  3. Click and drag the "Hello, world!" from the upper left corner of the phone display to the center of the screen.
  4. In the project file system on the left side of the window, open the values folder.
  5. In the values folder, double-click the strings.xml file.
  6. In this file, find the line "Hello world!".
  7. After the "Hello world!" message, add "Welcome to my app!"
  8. Navigate back to the activity_main.xml tab.
  9. Make sure that your centered text now reads "Hello world! Welcome to my app!"

Step 4: Add a Button to the Main Activity

Add a Button to the Main Activity
NextPageButton.jpg
  1. Navigate to the Design tab of the activity_main.xml display.
  2. In the Palette menu to the left of the phone display, find Button (under the heading Widgets).
  3. Click and drag Button to be centered underneath your welcome message.
  4. Make sure your button is still selected.
  5. In the Properties menu (on the right side of the window), scroll down to find the field for "text."
  6. Change the text from "New Button" to "Next Page."

Step 5: Create a Second Activity

Create a Second Activity
SecondPageString.jpg
SecondPageProperties.jpg

  1. At the top of the project's file system tree, right click on "app."
  2. Navigate through to New > Activity > Blank Activity.
  3. Change the name of this activity to "SecondActivity".
  4. Click "Finish."
  5. Make sure you are in the Design view of activity_second.xml.
  6. Drag the text box in the upper left of the phone display down to the center as you did on the Main Activity.
  7. With the text box still selected, find the "id" field in the Properties menu on the right, and set it to "text2".
  8. Open strings.xml again.
  9. Add a new line under "Hello world! Welcome to my app!" that reads "Welcome to the second page!".
  10. Navigate back to activity_second.xml.
  11. Select the text box again.
  12. In the Properties pane, set the "text" field to "@string/second_page".
  13. Make sure that the text box now reads "Welcome to the second page!" and is in the center of the screen in the phone display.

Step 6: Write the Button's "onClick" Method

Write the Button's "onClick" Method
GoTo.jpg
Import.jpg
  1. Select the MainActivity.java tab along the top of the work environment.
2. Add the following lines of code at the end of the onCreate method:
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.onClickListener() {
@Override
public void onClick(View v) {
goToSecondActivity();
}
});
3. Add the following method to the bottom of the MainActivity class:
private void goToSecondActivity() {
Intent intent = new Intent(this, SecondActivity.class);
startActivity(intent);
}

4. Click the + next to import at the third line of MainActivity.java to expand the import statements.
5. Add the following to the end of the import statements if they are not already there:
import android.content.Intent;
import android.view.View;
import android.widget.TextView;

Step 7: Test the Application

Test the Application
ChooseDevice.jpg
  1. Click the green play symbol from the toolbar at the top of the Android Studio window.
  2. When the "Choose Device" dialog apperas (this may take a few moments), select the "Lauch emulator" option.
  3. Click OK.
  4. When the emulator opens (this too could take awhile), the app will automatically launch the app upon the virtual phone being unlocked.
  5. Make sure that all of your text displays correctly and that the button takes you to the next page.

Step 8: Up, Up, and Away!

Up, Up, and Away!

ScreenTwo.jpg
Congrats! You've now completed your first Android application with some basic functionality. Your finished app should have a page greeting the user and a button that takes the user to a second page.
From here you have the cursory knowledge you need to go on to learn all there is to know about Android application development.

Comments

Popular posts from this blog

How to Build a Community with Facebook Groups

Last year , Facebook started turning its focus towards the development of Facebook Groups (shifting away from the News Feed.) An average Facebook user is a member of about thirty groups. However, not many groups are providing content relevant and valuable enough to bring these communities closer together. If you haven’t noticed yet, you probably will, because this change will affect how you interact and share with your community and content. It is also relevant for your social media marketing efforts. To support group owners, Facebook has added some helpful new tools and features that allow them to build and manage their communities more effectively. The Benefits of Facebook Groups for Businesses With a Facebook group that you have and manage, you can build an entire community. In return, it will give you many opportunities for: Increased website traffic Increased industry authority Product feedback Customer acquisition

What it Cost to Build and Design a Website in Nigeria

Before building a website for your business, it is important to know the costs involved. This will ensure you budget adequately for the project. Some business owners think building a website is a one-off thing. You just build it and you go to sleep. However, there are fixed costs and recurrent costs involved in building a business website . So, here are a few items to add to your budget. However, it is important to note that the cost of building a website depends on the complexity of its implementation. For example, a simple 5-page business website will usually cost much less to build compared to web applications like eCommerce websites, a social network sites, or betting websites. This means that there is no fixed cost for building a website. The cost of building websites vary widely. One may cost 100,000 Naira ($280) to build while another could cost up to $1 billion. The purpose of this article is to show you the different cost components so that you will

Get our GSM DATABASE of over 21 Million numbers classified by State and Local Government Areas

Buy Millions of Nigeria Local Government and State Based GSM Phone Numbers at very affordable rate. The benefits of getting these numbers are just too enormous: Boost your sales You can use these numbers to boost your sales and business exposure by presenting your products and services to the right targeted people, in the right place and at the right time Connect with the right people These numbers are not only ideal for businesses; If you are a politician that need to get the confidence of the electorate. You can use our database for your electioneering campaign and political awareness. We have millions of Phone numbers that are classified on a state-by-state and even down to LGAs basis to ensure that you can direct and target your messages to a particular set of people in any area and location in Nigeria. Do everything: endless possibilities These numbers are perfect for you whether your goal is to sell, promote, inform, notify or simply to create awareness