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.exams; // w ww . j a va 2s . co m import java.util.ArrayList; 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.R; import com.llenguatges.digitalcampus.adapters.ExamAdapter; import com.llenguatges.digitalcampus.database.ExamTable; import com.llenguatges.digitalcampus.objects.Exam; public class ExamsActivity extends Activity { private List<Exam> examsArray; private ExamTable et; /** * Start interacting with the user. * Called when previous activity not finished. */ protected void onResume() { super.onResume(); setExams(); } /** * 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_exams); ActionBar actionBar = getActionBar(); actionBar.setSubtitle("Students managment"); actionBar.setDisplayHomeAsUpEnabled(true); } /** * Initialize the contents of the Activity's standard options menu. */ public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.exams_menu, menu); return true; } /** * Set Activity's view and initialize UI actions */ public void setExams() { examsArray = new ArrayList<Exam>(); et = new ExamTable(getApplicationContext()); examsArray = et.GetDataFromTable(); ListView listView = (ListView)findViewById(R.id.examsListView); ExamAdapter examsAdapter = new ExamAdapter(getApplicationContext(), examsArray); listView.setAdapter(examsAdapter); listView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View view, int position, long arg3) { Intent intent = new Intent().setClass(ExamsActivity.this, NewExamActivity.class); long id = examsArray.get(position).getId(); intent.putExtra("id", id); startActivity(intent); } }); } /** * 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_exam: Intent intent = new Intent().setClass(ExamsActivity.this, NewExamActivity.class); intent.putExtra("exam", 0); startActivity(intent); return true; default: return super.onOptionsItemSelected(item); } } }