Back to project page activity-tracker.
The source code is released under:
MIT License
If you think the Android project activity-tracker 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 org.hopto.mjancola.activity; /*from ww w.j a v a 2 s .c om*/ /* public class ActivityTracker extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activitytracker); } } */ import android.app.ListActivity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ListAdapter; import android.widget.ListView; import org.hopto.mjancola.R; /** * The main activity of the API library demo gallery. * <p> * The main layout lists the demonstrated features, with buttons to launch them. */ public final class ActivityTracker extends ListActivity { /** * A custom array adapter that shows a {@link FeatureView} containing details about the demo. */ private static class CustomArrayAdapter extends ArrayAdapter<DemoDetails> { /** * @param demos An array containing the details of the demos to be displayed. */ public CustomArrayAdapter(Context context, DemoDetails[] demos) { super(context, R.layout.feature, R.id.title, demos); } @Override public View getView(int position, View convertView, ViewGroup parent) { FeatureView featureView; if (convertView instanceof FeatureView) { featureView = (FeatureView) convertView; } else { featureView = new FeatureView(getContext()); } DemoDetails demo = getItem(position); featureView.setTitleId(demo.titleId); featureView.setDescriptionId(demo.descriptionId); return featureView; } } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ListAdapter adapter = new CustomArrayAdapter(this, DemoDetailsList.DEMOS); setListAdapter(adapter); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.activity_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection if (item.getItemId() == R.id.menu_legal) { startActivity(new Intent(this, LegalInfoActivity.class)); return true; } if (item.getItemId() == R.id.menu_activity_recognition) { startActivity(new Intent(this, ActivityRecognitionActivity.class)); return true; } if (item.getItemId() == R.id.menu_my_location) { startActivity(new Intent(this, MyLocationDemoActivity.class)); return true; } return super.onOptionsItemSelected(item); } @Override protected void onListItemClick(ListView l, View v, int position, long id) { DemoDetails demo = (DemoDetails) getListAdapter().getItem(position); startActivity(new Intent(this, demo.activityClass)); } }