Back to project page digitalcampus.
The source code is released under:
MIT License
If you think the Android project digitalcampus listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.llenguatges.digitalcampus.students; /*from w ww . ja va 2s .c om*/ import java.util.ArrayList; import java.util.List; import android.app.ActionBar; import android.app.Activity; import android.os.Bundle; import android.view.MenuItem; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; import com.llenguatges.digitalcampus.R; import com.llenguatges.digitalcampus.adapters.StudentSubjectsAdapter; import com.llenguatges.digitalcampus.database.StudentSubjectTable; import com.llenguatges.digitalcampus.database.StudentTable; import com.llenguatges.digitalcampus.database.SubjectTable; import com.llenguatges.digitalcampus.objects.Student; import com.llenguatges.digitalcampus.objects.Subject; public class InformationActivity extends Activity { private Student student; private long id; private List<Long> subjectIdList; private List<Subject> subjectList; private StudentSubjectTable sst; private SubjectTable st; private ListView listView; private StudentSubjectsAdapter adapter; /** * Start interacting with the user. * Called when previous activity not finished. */ protected void onResume(){ super.onResume(); setSubjects(); } /** * Called when the activity is first created. * This is where you all of static set up: customize ActionBar. * This method also provides you with a Bundle containing the * activity's previously frozen state, if there was one. */ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle extras = getIntent().getExtras(); setContentView(R.layout.activity_students_info); ActionBar acBar = getActionBar(); acBar.setSubtitle("Student information"); acBar.setDisplayHomeAsUpEnabled(true); id = extras.getLong("student"); student = new Student(0, null, null, null, null, null, false, null); StudentTable st = new StudentTable(getApplicationContext()); student = st.GetStudentById(id); this.setStudentFirstName(student.getFirstName()); this.setStudentLastName(student.getLastName()); this.setStudentDescription(student.getDescription()); this.setStudentAge(student.getAge()); if(student.getGender() == "M"){ this.setStudentGender("Male"); }else{ this.setStudentGender("Female"); } this.setPhoto(); } /** * Set student's image image view */ private void setPhoto() { ImageView iv = (ImageView) findViewById(R.id.studentImage); if(student.getPhoto() != null){ iv.setImageBitmap(student.getPhoto()); } } /** * Set student's first name text view * @param firstName */ public void setStudentFirstName(String firstName) { TextView studentFirstName = (TextView) findViewById(R.id.studentFirstName); studentFirstName.setText(firstName); } /** * Set student's last name text view * @param lastName */ public void setStudentLastName(String lastName) { TextView studentLastName = (TextView) findViewById(R.id.studentLastName); studentLastName.setText(lastName); } /** * Set student's description text view * @param description */ public void setStudentDescription(String description) { TextView studentDescription = (TextView) findViewById(R.id.studentDescription); studentDescription.setText(description); } /** * Set student's age text view * @param age */ public void setStudentAge(String age) { TextView studentAge = (TextView) findViewById(R.id.studentAge); studentAge.setText(age); } /** * Set stundent's gender text view * @param gender */ public void setStudentGender(String gender) { TextView studentGender = (TextView) findViewById(R.id.studentGender); studentGender.setText(gender); } /** * Set student's subjects */ public void setSubjects() { subjectList = new ArrayList<Subject>(); subjectIdList = new ArrayList<Long>(); st = new SubjectTable(getApplicationContext()); sst = new StudentSubjectTable(getApplicationContext()); subjectIdList = sst.GetSubjectIdFromTableByStudentId(id); for(int i = 0; i < subjectIdList.size(); i++){ subjectList.add(st.GetSubjectById(subjectIdList.get(i))); } adapter = new StudentSubjectsAdapter(getApplicationContext(), subjectList); listView = (ListView) findViewById(R.id.studentsSubjectsListView); listView.setAdapter(adapter); } /** * This hook is called whenever an item in your options menu is selected. */ public boolean onOptionsItemSelected(MenuItem item) { // Handle presses on the action bar items switch (item.getItemId()) { case android.R.id.home: finish(); return true; default: return super.onOptionsItemSelected(item); } } }