/ Android

A Simple Notepad app using Android Studio


Photo by Elijah O'Donell / Unsplash
A daily purpose, simple notepad app can be easily created by means of Android Studio and can be used ocassionaly by the code and steps provided in this article.

Software requirements:

  1. Android studio (prefereably latest version) IntelIJ platform
  2. Any android device (for testing)

Hardware requirements:

  1. Intel core processor
  2. 4GB RAM
  3. 1GB memory space (for studio)

Generating the application:

Install Android Studio and open it. Start a New project and name the app. Choose blank activity for the basic layout and hit finish button. Android studio will generate the basic app project framework.

img1

Since it is a notepad app, focus has to be given for adding each activity as the user clicks the plus button i.e, adding a new note. For this a separate file named NoteActivity.java has to be created for controlling each note.

Go to app folder->java->file with app name-> right click->new->activity->empty activity->name the new java file -> finish. Add the following code:

img2

Inorder to view the saved notes in a list view, we should change the RelativeLayout of MainActivity to ListView layout. This is changed in the content_main.xml by adding the code below.

img3

The aesthetic part of the app and UI are controlled by XML files. MainActivity has two xml files ; activity_main.xml and activity_note.xml.

img4

img5

img6

A template layout is only provided by the Android development libraries. This item defines the styles used to render out ListView on screen. It is an XML file which contains one item.

To define the item as a list, simply right click the simple_list_item1 text in the MainActivity.java file and a menu will appear. Select GoTo, select the declaration menu item and Android Studio will open up that layout (XML) file for you. This is basic style for a simple list view. The screen shown below will be created as soon as you create it.

img 11

Another XML file called string.xml file is required for the functioning of pop-up messages on button clicks and other strings used in the app.It is a resource file.

img12

All these  XML files and the NoteActivity.java has to be now incorporated into MainActivity.java to include all the functionalities of each xml files and java class into the application.

img7

img9

Saving the notes:

Once UI is done we need to save the notes created by the user upon clicking the “Save” button. The code for adding this functionality is as follows:

img10

After filling all this code, go ahead and compile the code. Debug all the errors and after the build is finished run the generated app on an emulator or any android device with the help of ADB (Android Device Bridge).

Final app will look like this:

Screenshot_2016-06-11-22-09-59

Screenshot_2016-06-14-00-16-40

Screenshot_2016-06-11-22-10-10

Hope you'll try this out!