Android TutorialsDeveloping A Simple Application In Android

Developing A Simple Application In Android

In our blog today you will learn to develop a simple application in android. We will show you the simple steps to follow

  • Steps to develop simple application :
  1. Open the eclipse application file.
  2. A Workspace Launcher dialog box will appear.
  3. Browse to the folder where you want to save your workspace.
  4. A welcome screen will appear.
  5. Close the welcome screen.
  6. Go to File->New->Android Application Project.
  7. 1

  8. After clicking Android Application Project a “New Android Application Window ” will appear.
  9. Here we have to specify the Application Name.
  10. Also mention the Package name (Any name) example: com.bean.Application Name .
  11. Select the Minimum Required SDK from the drop down list , also select the Target SDK
  12. The window will look like….
  13. 2

  14. After clicking next a window will appear in which uncheck the create custom launcher icon and click on next.
  15. Create activity window will appear which consists of three activities like Blank Activity ,Fullscreen Activity, Master/Detail Flow.
  16. Select the Blank Activity and click on next button.
  17. 4

  18. Now Blank Activity Window will appear which consists of the Activity Name of the workspace , Layout Name and Navigation is to be kept none.
  19. Main Activity is the name of the Workspace.
  20. The window will look as shown in the figure below.
  21. Click Finish.
  22. Workspace will get opened with the MainActivity that is the runnable code.
  23. 5

  24. Now we are going to develop a simple application so we are not going to have an onCreateOptionsMenu so delete the code for the respective.
  25. Now go to import in the MainActivity and delete the import statement import android.view.Menu;
  26. As we are not using onCreateOptionsMenu.
  27. The MainActivity is the controller of our application and activity_main.xml is the view of our application
  28. Now the window will look like this…
  29. 5

  30. Now go to activity_main.xml and delete the Hello World text from the application Layout.
  31. Now from Graphical Layout ,select Form Widgets and from this select and drag Large Text and a Button on the android application screen.
  32. Once you are done with it your screen will look like as shown below…
  33. 7

  34. Now go to the properties by clicking on the activity_main.xml.
  35. Go to Button properties and in that reset the android:text=”Say Hi” .here we are only changing the name of the button.
  36. Also delete the text in the TextView i.e android:text=”Large Text”.
  37. Now the window will look like as shown..
  38. 8

  39. Now there is id-textView1 in the TextView which we want to find in the MainActivity.java.
  40. So now go to MainActivity.java and now write the code which will respond to the button touch.
  41. When you specify the (View v) the system doesn’t understand it and gives erron with a red mark sign on its left, on clicking, it specifies whether we want to import the View .
  42. So write the code inside the main activity:
    Public void onBtnTouch(View v)
    {
    TextView tv=(TextView) findViewById(R.id.textview1);
    tv.setText(“**Welcome To INDIA**”);
    }
  43. The window will look as follows:
  44. 9

  45. So on click activity should be specified in the button properties i.e android:onClick=”onBtnTouch” in the activity_main.xml
  46. 10

  47. Now when you run the MainActivity.java a Run As window will appear.Select the Android Application and click OK.
  48. 11

  49. On Clicking OK an Android Home Screen will appear.
  50. 12

  51. On clicking applications various applications are displayed along with your application.For example: Rhymes as shown in figure.
  52. 13

  53. If we click on Rhymes application, it will display the button we had taken.
  54. 14

  55. When we click on the button “Say Hi” ,it will display the Written Text.
  56. 15

  57. Thus we have created a simple android application.

Exclusive content

- Advertisement -

Latest article

21,501FansLike
4,106FollowersFollow
106,000SubscribersSubscribe

More article

- Advertisement -