/[aagtl_public1]/src/com/zoffcc/applications/aagtl/EmulatedMenuView.java
aagtl

Contents of /src/com/zoffcc/applications/aagtl/EmulatedMenuView.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (show annotations) (download)
Sat Aug 1 08:47:10 2015 UTC (8 years, 7 months ago) by zoffadmin
File size: 2634 byte(s)
1.0.35
1 /**
2 * aagtl Advanced Geocaching Tool for Android
3 * loosely based on agtl by Daniel Fett <fett@danielfett.de>
4 * Copyright (C) 2010 - 2013 Zoff <aagtl@work.zoff.cc>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21 package com.zoffcc.applications.aagtl;
22
23 import android.content.Context;
24 import android.graphics.Color;
25 import android.view.View;
26 import android.widget.AdapterView;
27 import android.widget.ArrayAdapter;
28 import android.widget.ListView;
29
30 public class EmulatedMenuView extends ListView
31 {
32 private int selected_id = -1;
33 public String[] MenuItemsList = null;
34 public int[] MenuItemsIdMapping = null;
35 Context c;
36 aagtl main_aagtl;
37
38 public EmulatedMenuView(Context context, aagtl main)
39 {
40 super(context);
41 c = context;
42 main_aagtl = main;
43
44 MenuItemsList = new String[1];
45 MenuItemsIdMapping = new int[1];
46 for (int i = 0; i < 1; i++)
47 {
48 MenuItemsList[i] = "_";
49 MenuItemsIdMapping[i] = i;
50 }
51
52 ArrayAdapter<String> adapter = new ArrayAdapter<String>(c, android.R.layout.simple_list_item_1, MenuItemsList);
53 setAdapter(adapter);
54 setOnItemClickListener(new AdapterView.OnItemClickListener()
55 {
56 public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3)
57 {
58 Object o = getItemAtPosition(position);
59 String str = (String) o;//As you are using Default String Adapter
60 //System.out.println("aagtl:mitem=" + str + " pos=" + position);
61 setVisibility(View.INVISIBLE);
62 main_aagtl.onOptionsItemSelected_wrapper(MenuItemsIdMapping[position]);
63 }
64 });
65 this.setBackgroundColor(Color.BLACK);
66 }
67
68 void set_adapter(String[] ml, int[] mid)
69 {
70 for (int i = 0; i < MenuItemsList.length; i++)
71 {
72 MenuItemsList[i] = null;
73 }
74 MenuItemsList = null;
75 MenuItemsIdMapping = null;
76
77 MenuItemsList = ml;
78 MenuItemsIdMapping = mid;
79
80 ArrayAdapter<String> adapter = new ArrayAdapter<String>(c, android.R.layout.simple_list_item_1, MenuItemsList);
81 setAdapter(adapter);
82 }
83 }

   
Visit the aagtl Website