/** * aagtl Advanced Geocaching Tool for Android * loosely based on agtl by Daniel Fett * Copyright (C) 2010 - 2013 Zoff * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ package com.zoffcc.applications.aagtl; import android.app.Activity; import android.app.ListActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.ArrayAdapter; import android.widget.ListView; public class EmulatedMenuActivity extends ListActivity { private int selected_id = -1; public static String[] MenuItemsList = null; public static int[] MenuItemsIdMapping = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, MenuItemsList); setListAdapter(adapter); // this.getListView().setFastScrollEnabled(true); } @Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); // System.out.println("sel object=" + getListView().getItemAtPosition(position).toString()); // --> the string of the menuitem // Get the item that was clicked this.selected_id = MenuItemsIdMapping[position]; // close this activity executeDone(); } private void executeDone() { Intent resultIntent = new Intent(); resultIntent.putExtra("selected_id", this.selected_id); setResult(Activity.RESULT_OK, resultIntent); finish(); } }