-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQButtonDialog.java
More file actions
83 lines (70 loc) · 2.22 KB
/
QButtonDialog.java
File metadata and controls
83 lines (70 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package com.fontlose.relayctrl;
import java.util.ArrayList;
import java.util.HashMap;
import android.app.AlertDialog;
import android.content.Context;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.SimpleAdapter;
import android.widget.AdapterView.OnItemClickListener;
/**
* @author root
* ����ButtonDialog
*
*
*
*/
public class QButtonDialog {
ArrayList<HashMap<String, Object>> data = new ArrayList<HashMap<String, Object>>();
GridView menuGrid;
View menuView;
AlertDialog menuDialog;
//QPopupWindow popupWindow;
OnItemClickListener itemClick;
public void close()
{
menuDialog.dismiss();
}
public QButtonDialog(Context mct) {
super();
SimpleAdapter simperAdapter =
new SimpleAdapter(mct, data,R.layout.item_menu, new String[] { "itemImage", "itemText" },
new int[] { R.id.item_image, R.id.item_text });
menuView = View.inflate(mct, R.layout.gridview_menu, null);
menuGrid = (GridView) menuView.findViewById(R.id.gridview);
menuGrid.setAdapter(simperAdapter);
menuDialog = new AlertDialog.Builder(mct).create();
/*QPopupWindow popupWindow = new QPopupWindow(menuView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,true);
popupWindow.setOutsideTouchable(true);
popupWindow.setTouchable(true);
popupWindow.setBackgroundDrawable(new BitmapDrawable());
popupWindow.setAnimationStyle(R.style.PopupAnimation);
popupWindow.update(); */
menuDialog.setView(menuView);
menuGrid.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3)
{ //QButtonDialog.this.onItemClick(arg0,arg1,arg2,arg3);
if(itemClick!=null)
itemClick.onItemClick(arg0, arg1, arg2, arg3);
}
});
}
public void addMenu(String text,int image)
{
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("itemImage", image);
map.put("itemText", text);
data.add(map);
}
public void show( )
{
menuGrid.invalidate();
//popupWindow.showAtLocation(parent, Gravity.CENTER, 0, 0) ;
menuDialog.show();
}
public void setOnItemClickListener(OnItemClickListener itemclick)
{
itemClick=itemclick;
}
}