Difference between revisions of "Teams Winter 2011/team1/Android/Implement View Option"

From CDOT Wiki
Jump to: navigation, search
(Created page with '=== 6. Implement View Option === 6.1. Inside the <code>ContactList</code> class add the following code to implement view option: <pre> case R.id.item3: Student view…')
 
(6. Implement View Option)
 
Line 1: Line 1:
 
=== 6. Implement View Option ===
 
=== 6. Implement View Option ===
 
6.1. Inside the <code>ContactList</code> class add the following code to implement view option:
 
6.1. Inside the <code>ContactList</code> class add the following code to implement view option:
  <pre>
+
  <source lang="java">
 
     case R.id.item3:
 
     case R.id.item3:
 
         Student viewStudent = (Student)contactsList.getSelectedItem();
 
         Student viewStudent = (Student)contactsList.getSelectedItem();
Line 12: Line 12:
 
         }
 
         }
 
         break;
 
         break;
  </pre>
+
  </source>
 
6.2. Run the application, select a student and select "'''View Student"''' from the menu: <br/>
 
6.2. Run the application, select a student and select "'''View Student"''' from the menu: <br/>
 
[[Image: A_view.png | 450px ]]
 
[[Image: A_view.png | 450px ]]

Latest revision as of 12:18, 28 March 2011

6. Implement View Option

6.1. Inside the ContactList class add the following code to implement view option:

    case R.id.item3:
         Student viewStudent = (Student)contactsList.getSelectedItem();
         if(viewStudent != null) {
             Toast.makeText(this.getApplicationContext(), "First Name: " + viewStudent.getFirstname()
                 + " \nLast Name: " + viewStudent.getLastName()
                 + " \nE-mail: " + viewStudent.getEmail(), Toast.LENGTH_LONG).show();   
         } else {
             showDialog("No contact was selected!");
         }
         break;

6.2. Run the application, select a student and select "View Student" from the menu:
A view.png