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 w w . j ava 2s .c o m import java.util.List; import android.app.ActionBar; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; import com.llenguatges.digitalcampus.MyApplication; import com.llenguatges.digitalcampus.R; import com.llenguatges.digitalcampus.adapters.StudentAdapter; import com.llenguatges.digitalcampus.database.StudentTable; import com.llenguatges.digitalcampus.objects.Student; public class StudentsActivity extends Activity { private List<Student> studentArray; private ListView listView; private StudentAdapter studentAdapter; private StudentTable studentTable; /** * 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); setContentView(R.layout.activity_students); ActionBar actionBar = getActionBar(); actionBar.setSubtitle("Students managment"); actionBar.setDisplayHomeAsUpEnabled(true); } /** * Start interacting with the user. * Called when previous activity not finished. */ protected void onResume(){ super.onResume(); loadView(); } /** * Initialize the contents of the Activity's standard options menu. */ public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.students_menu, menu); return true; } /** * This hook is called whenever an item in your options menu is selected. */ public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: this.finish(); return true; case R.id.new_student: Intent intent = new Intent().setClass(StudentsActivity.this, NewStudentActivity.class); startActivity(intent); return true; default: return super.onOptionsItemSelected(item); } } /** * Load Activity's view and initialize UI actions */ public void loadView() { MyApplication myApp = (MyApplication) getApplication(); studentArray = myApp.getStudent(); listView = (ListView)findViewById(R.id.mainStudentsListView); studentTable = new StudentTable(getApplicationContext()); studentArray = studentTable.GetDataFromTable(); studentAdapter = new StudentAdapter(getApplicationContext(), this, myApp); listView.setAdapter(studentAdapter); listView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View view, int position, long arg3) { Intent intent = new Intent().setClass(StudentsActivity.this, InformationActivity.class); Student student = new Student(0, null, null, null, null, null, false, null); student = studentArray.get(position); intent.putExtra("student", student.getId()); startActivity(intent); } }); } }