Friday, November 2, 2018

Create your first android app with simple steps





The use of Android devices is already increased due to the increasing demand of customers. Android Studio is the best platform to build applications. It is an open source which anyone can use. If you have some basic knowledge about java then it will be good for you. This tutorial will help you to build a simple android app.

Follow these simple steps:

  1. Go to http://developer.android.com/sdk/index.html. Android Studio is an open source platform. Download and Install it.
  2. Open android studio and select “Start a new Android Studio project” and give it a name whatever you want.
  3. Give the company name if you have any and set the location of the project. Make sure the phone and tablet tab is checked.
  4. The SDK should be small as compare to your operating system level so that the app will work perfectly.
  5. Click next.
  6. Select the blank activity from all other activities and click next.
  7. Leave all other options same and click next.
  8. Just go the activity_main.xml and make sure this XML is connected to the activity main.
  9. Drag the hello world text and place anywhere.
  10. You will find a values folder on the left side of the window. Open it and change the Hello world text by clicking the strings.xml file.
  11. Change the hello world text as per your wish.
  12. Go back to the activity_main.xml and find a button which is located on the left side of the display.
  13. Click the button and drag to the display.
  14. Make sure your button is still selected and change the text and id of the button by going to the properties.
  15. Click the app folder in the left corner of the screen. Click new and create a blank activity and name it “second_activity”.
  16. Click finish and make sure you are in activity_second.xml.
  17. Same as like main activity drag the text box from the left side of the display and put it into your layout center.
  18. Just press the text box and go the properties and change the id of the text to “text2”.
  19. Go to strings.xml.
  20. As per your wish change the text hello world text there.
  21. Move back to the activity_second.xml.
  22. Now go to the text box.
  23. Change the text field to "@string/second_page" from properties of that text.
  24. In the further step make sure the text display the changes you have made in the text.
  25. Find the oncreate method on Main activity. Put the mentioned code there.
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.onClickListener() {
@Override
public void onClick(View v) {
goToSecondActivity();
}
});


   26. Add the following method to the bottom of the MainActivity class:

        private void goToSecondActivity() {
        Intent intent = new Intent(this, SecondActivity.class);
        startActivity(intent);
}


   27. Just click + next and import all the necessary files in Main activity.
   28 You will see a green play symbol at the top of the display. Press it and a screen will be generated.
   29. Choose one of the emulators from given mobile phones and click on Launch emulator.
   30. Click ok.
   31. The app will automatically install and run from the emulator, Make sure the text display correctly check the functionality of the button by clicking it. If the second activity displayed by clicking the button then your app is working fine. So that’s it enjoy your app you are now an application developer.

No comments:

Post a Comment