Add Notes to the Detail Form
Next, we need LunchList to make use of the notes. To do this, first add the following TableRow above the Save button in our TableLayout in LunchList/res/layout/main.xml:
<TableRow>
<TextView android:text="Notes:" />
<EditText android:id="@+id/notes"
android:singleLine="false"
android:gravity="top"
android:lines="2"
android:scrollHorizontally="false"
android:maxLines="2"
android:maxWidth="200sp"
/>
</TableRow>
Then, we need to modify the LunchList activity itself, by:
1. Adding another data member for the notes EditText widget defined above
2. Find our notes EditText widget as part of onCreate(), like we do with other EditText widgets
3. Save our notes to our restaurant in onSave
4. Restore our notes to the EditText in onListClick
At this point, you can recompile and reinstall the application to see your notes field in action:
<TableRow>
<TextView android:text="Notes:" />
<EditText android:id="@+id/notes"
android:singleLine="false"
android:gravity="top"
android:lines="2"
android:scrollHorizontally="false"
android:maxLines="2"
android:maxWidth="200sp"
/>
</TableRow>
Then, we need to modify the LunchList activity itself, by:
1. Adding another data member for the notes EditText widget defined above
2. Find our notes EditText widget as part of onCreate(), like we do with other EditText widgets
3. Save our notes to our restaurant in onSave
4. Restore our notes to the EditText in onListClick
At this point, you can recompile and reinstall the application to see your notes field in action:
The notes field in the detail form

No comments:
Post a Comment