Tutorial description: The product of this tutorial is to invoke (from MENU) another screen to insert a new record. The first screen is the list of all records. User is able to add a new record through this screen. The screenshots below is the output.
Before you proceed with the tutorial, you might want to read the previous tutorial - Update Record by long-press ListView - Android database SQLite (p6)
Download the complete code here http://khirulnizam.com/android/FSTMDirektori.zip
STEP 1: Add a new screen named AddNewRecord
Right-click on the project name –>New –> Other… Select the Android Activity –> Blank Activity. Provide the new Activity (screen) name AddNewRecord
Provide the Activity Name as AddNewRecord, and hit Finish
STEP 2: Design the layout for AddNewRecord screen
The XML file
The Java code to perform Save New Record.
STEP 3: Add MENU on ActionBar to call the AddNewRecord screen
Get back to the main screen (DisplayList.java). Add the onCreateOptionsMenu and onOptionsItemSelected in the DisplayList.java
DisplayList.java – updated
Now, try compiling and run…