Difference between revisions of "Teams Winter 2011/team1/Android/Adding Functionality to Main Screen Elements"

From CDOT Wiki
Jump to: navigation, search
(Created page with '=== 3. Adding Functionality to Main Screen Elements === 3.1. Inside the <code>ContractList</code> class create a String array: <pre> protected String[] myContacts = { "Anast…')
 
Line 2: Line 2:
 
3.1. Inside the <code>ContractList</code> class create a String array:
 
3.1. Inside the <code>ContractList</code> class create a String array:
 
  <pre>
 
  <pre>
     protected String[] myContacts = { "Anastasia Semionova", "Minoo Ziaei",
+
     protected String[] studentList = { "Anastasia Semionova", "Minoo Ziaei",
 
             "Ladan Zadeh", "Sergiu Ecob" };
 
             "Ladan Zadeh", "Sergiu Ecob" };
 
  </pre>
 
  </pre>
3.2.
+
3.2. Populate the listView on the main screen:
 +
<pre>
 +
  ListAdapter adapter = new ArrayAdapter<String>(this,
 +
                android.R.layout.simple_list_item_1, studentList);
 +
        ListView contactsList = (ListView) findViewById(R.id.listView1);
 +
        contactsList.setAdapter(adapter);
 +
</pre>

Revision as of 13:43, 25 March 2011

3. Adding Functionality to Main Screen Elements

3.1. Inside the ContractList class create a String array:

    protected String[] studentList = { "Anastasia Semionova", "Minoo Ziaei",
            "Ladan Zadeh", "Sergiu Ecob" };
 

3.2. Populate the listView on the main screen:

   ListAdapter adapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, studentList);
        ListView contactsList = (ListView) findViewById(R.id.listView1);
        contactsList.setAdapter(adapter);