Button into PopupView

  • Replies:1
Сергей Врублевский
  • Forum posts: 1

Dec 6, 2012, 7:48:24 PM via Website

I have a LinearLayout into my PopupView, and a button into this LinearLayout. Event listener of this button works correctly, but animation of pressing (highlighting) is not starting. What I did wrong? Please, help!
1public class PopupView extends View
2{
3 private PopupWindow popUp;
4 private Button buttonOk;
5 private OnClickListener onClick;
6 private LayoutParams params;
7 private int popUpWidth = 0;
8 private int popUpHeight = 0;
9 private int popUpX, popUpY;
10
11 public PopupView(Context context, View parent)
12 {
13 super(context);
14 popUp = new PopupWindow(context);
15 popUpLayout = new LinearLayout(context);
16 buttonOk = new Button(context);
17 buttonOk.setText("OK");
18 buttonOk.setId(1);
19
20 params = new LayoutParams(LayoutParams.WRAP_CONTENT,
21 LayoutParams.WRAP_CONTENT);
22 popUpLayout.setOrientation(LinearLayout.VERTICAL);
23 popUp.setContentView(popUpLayout);
24
25 onClick = new OnClickListener()
26 {
27 public void onClick (View v)
28 {
29 switch (v.getId())
30 {
31 case 1:
32 System.out.println("OK pressed!");
33 break;
34
35 case 2:
36
37 break;
38 }
39 }
40 };
41
42 buttonOk.setOnClickListener(onClick);
43
44 popUpLayout.removeAllViews();
45 popUpLayout.addView(buttonOk, params);
46
47
48 popUpWidth = 200;
49 popUpHeight = 400;
50
51 popUpX = 300;
52 popUpY = 300;
53
54 popUp.showAtLocation(parent, Gravity.NO_GRAVITY, popUpX, popUpY);
55 popUp.update(popUpX, popUpY, popUpWidth, popUpHeight);
56 }
57}

Reply
Ashish Tripathi
  • Forum posts: 211

Feb 4, 2013, 12:49:29 PM via Website

Explain briefly. Not getting your's problem.

Reply