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.subjects; /* ww w . ja va 2 s.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.SubjectAdapter; import com.llenguatges.digitalcampus.objects.Subject; public class SubjectsActivity extends Activity { private List<Subject> subjectList; private ListView listView; private SubjectAdapter adapter; /** * Start interacting with the user. * Called when previous activity not finished. */ protected void onResume(){ super.onResume(); loadView(); } /** * 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_subjects); ActionBar actionBar = getActionBar(); actionBar.setSubtitle("Subject managment"); actionBar.setDisplayHomeAsUpEnabled(true); } /** * Load Activity's view and initialize UI actions */ private void loadView(){ MyApplication myApp = (MyApplication) getApplication(); subjectList = myApp.getSubjects(); listView = (ListView) findViewById(R.id.lv); adapter = new SubjectAdapter(getApplicationContext(), this, myApp); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View v, int position, long arg3) { Intent intent = new Intent().setClass(SubjectsActivity.this, InformationActivity.class); Subject subject = new Subject(); subject = subjectList.get(position); intent.putExtra("subject", subject.id); startActivity(intent); } }); } /** * Initialize the contents of the Activity's standard options menu. */ public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.subjects_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_subject: Intent intent = new Intent().setClass(SubjectsActivity.this, NewSubjectActivity.class); startActivity(intent); return true; default: return super.onOptionsItemSelected(item); } } }