This is a continuation from part 1.
Since in part one we got the Requirements and the Prototype, we will create a simple technical Document and then follow it to create our activities and the app.
Here is our simple technical document:
1. Screen 1:
-
- Title – Optional.
- TextArea for name of medicines.
- This is where the user will put note down with medicine names. Auto Text will send this note content to the contact if missed.
- Textarea will be 100 character long.
- TimePicker for the alarm.
- Must be able to set a specific time.
- Hour, min, AM/PM.
- TextBox for contact phone.
- this will be a phone field. We will have format.
- Button for saving value.
- Text: Enter.
- OnClick : Capture screen values and move on to the next screen.
2. Screen 2:
-
- Title – Optional
- Button for Edit
- Cancel alarm schedule.
- OnClick: go back to Screen 1.
- Button for Save.
- Save the time to start the alarm.
- Show message via Toast.
- Button for Cancel alarm.
- Cancel any alarm that was set in the past.
- Go back to screen 1.
3. Screen 3:
-
- Title – Optional.
- Button for acknowledge the alarm.
- Acknowledge the action and
- Keep the alarm as it.
- If not pressed within 2 hours, the app will send a Text to the phone number provided.
- Button to snooze the alarm.
- Sbooze for 5 min.
Now let’s dive down in the code
Start Visual Studio and create a new project.
I am targeting Min Android 2.1, you can support other ones if you wish. This mean my min supported device will have 2.1 version of Android.
I called the project SimpleMedicineTracker.
I also changed the package name to com.simple.medicinetracker and set the version to 1. API target level is 7.
Change the activity name to MainPage and Layout name to Main.
You need to add a label, text area, Text box, button and a label for debug purpose.
You can use the designers in Visual Studio to create the main screen, I have set the display as following
Your xml file should look something like the following.
1: <?xml version="1.0" encoding="utf-8"?>
2: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3: android:orientation="vertical"
4: android:layout_width="fill_parent"
5: android:layout_height="fill_parent"
6: android:minWidth="25px"
7: android:minHeight="25px">
8: <TextView
9: android:text="@string/EnterMedicinesLabel"
10: android:layout_width="wrap_content"
11: android:layout_height="wrap_content"
12: android:id="@+id/EnterMedicinesLabel" />
13: <EditText
14: android:text="@string/EnterMedicines"
15: android:inputType="textMultiLine"
16: android:layout_width="fill_parent"
17: android:layout_height="wrap_content"
18: android:id="@+id/TextEnterMedicineNames" />
19: <TimePicker
20: android:layout_width="fill_parent"
21: android:layout_height="wrap_content"
22: android:id="@+id/MedicineTime" />
23: <TextView
24: android:text="Enter Phone Number"
25: android:layout_width="wrap_content"
26: android:layout_height="wrap_content"
27: android:id="@+id/EnterPhoneLabel" />
28: <EditText
29: android:inputType="phone"
30: android:layout_width="fill_parent"
31: android:layout_height="wrap_content"
32: android:id="@+id/PhoneNumber"
33: android:phoneNumber="true" />
34: <Button
35: android:text="@string/Enter"
36: android:layout_width="fill_parent"
37: android:layout_height="wrap_content"
38: android:id="@+id/EnterMedicinesButton"
39: android:gravity="center"
40: android:capitalize="characters" />
41: <TextView
42: android:text="@string/ShowMedicinesLabel"
43: android:layout_width="wrap_content"
44: android:layout_height="wrap_content"
45: android:id="@+id/ShowMedicinesLabel" />
46: </LinearLayout>
Few things to note here
-
- all the android:text are coming from strings.xml file under Values folder
-
- Android declaration will have the button as wide as the screen and specific size.
android:layout_width="fill_parent" android:layout_height="wrap_content"
- Android declaration will have the button as wide as the screen and specific size.
So at this point you should have a project with Main Activity in it. This is screen 1.
Let’s keep this going on the next post.