Open main menu

CDOT Wiki β

Changes

Teams Winter 2011/team1/Android/Edit Contact

1,294 bytes added, 11:27, 7 April 2011
8.2 Create EditContactActivity
private String lastName;
private String email;
</source>
8.2.3 Make sure that on creation it adds the edit layout to the view, so change the OnCreate method:
<source lang="java">
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.edit); // adds edit layout to view
}
}
</source>
8.2.3 get the Intent of this Activity (later when starting this activity, we will send an Intent including the data of the selected student for editing). Then read he data from it and set the EditTexts values:
<source lang="java">
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.edit); // adds edit layout to view
 
Intent i = this.getIntent(); // get this page intent
 
// read the data from the Intent
EditText fNameEditText = (EditText) findViewById(R.id.firstNameEdit);
fNameEditText.setText(i.getStringExtra("oldFirstName"));
EditText lNameEditText = (EditText) findViewById(R.id.lastNameEdit);
lNameEditText.setText(i.getStringExtra("oldLastName"));
EditText emailEditText = (EditText) findViewById(R.id.emailEdit);
emailEditText.setText(i.getStringExtra("oldEmail"));
 
}
}
</source>
1
edit