Android UI——popuwindow实例
PopupWindow在android.widget包下,弹出窗口的形式展示。官方文档对该控件的描述是:“一个弹出窗口控件,可以用来显示任意视图(View),而且会浮动在当前 活动(activity)的顶部”。PopupWindow可以让我们实现多种自定义控件,例如:menu、alertdialog等弹窗似的View。实现中使用的 PopupWindow。这里做了简单封装,其中有三个类组成:PopuItem、PopuJar、PopupWindows。
1. public class PopuItem {
2. private Drawable icon;
3. private Bitmap thumb;
4. private String title;
5. private int actionId = -1;
6. private boolean selected;
7. private boolean sticky;
8.
9. /**
10. * Constructor
11. *
12. * @param actionId Action id for case statements
13. * @param title Title
14. * @param icon Icon to use
15. */
16. public PopuItem(int actionId, String title, Drawable icon) {
17. this.title = title;
18. this.icon = icon;
19. this.actionId = actionId;
20. }
21.
22. /**
23. * Constructor
24. */
25. public PopuItem() {
26. this(-1, null, null);
27. }
28.
29. /**
30. * Constructor
31. *
32. * @param actionId Action id of the item
33. * @param title Text to show for the item
34. */
35. public PopuItem(int actionId, String title) {
36. this(actionId, title, null);
37. }
38.
39. /**
40. * Constructor
41. *
42. * @param icon {@link Drawable} action icon
43. */
44. public PopuItem(Drawable icon) {
45. this(-1, null, icon);
46. }
47.
48. /**
49. * Constructor
50. *
51. * @param actionId Action ID of item
52. * @param icon {@link Drawable} action icon
53. */
54. public PopuItem(int actionId, Drawable icon) {
55. this(actionId, null, icon);
56. }
57.
58. /**
59. * Set action title
60. *
61. * @param title action title
62. */
63. public void setTitle(String title) {
64. this.title = title;
65. }
66.
67. /**
68. * Get action title
69. *
70. * @return action title
71. */
72. public String getTitle() {
73. return this.title;
74. }
75.
76. /**
77. * Set action icon
78. *
79. * @param icon {@link Drawable} action icon
80. */
81. public void setIcon(Drawable icon) {
82. this.icon = icon;
83. }
84.
85. /**
86. * Get action icon
87. * @return {@link Drawable} action icon
88. */
89. public Drawable getIcon() {
90. return this.icon;
91. }
92.
93. /**
94. * Set action id
95. *
96. * @param actionId Action id for this action
97. */
98. public void setActionId(int actionId) {
99. this.actionId = actionId;
100. }
101.
102. /**
103. * @return Our action id
104. */
105. public int getActionId() {
106. return actionId;
107. }
108.
109. /**
110. * Set sticky status of button
111. *
112. * @param sticky true for sticky, pop up sends event but does not disappear
113. */
114. public void setSticky(boolean sticky) {
115. this.sticky = sticky;
116. }
117. &nb
补充:移动开发 , Android ,