Как разместить пользовательское диалоговое окно в месте нажатия в Android? - PullRequest
3 голосов
/ 28 апреля 2011

Кто-нибудь может сказать, как разместить диалоговое окно или всплывающее окно в месте нажатия в Android?

Ответы [ 2 ]

2 голосов
/ 28 апреля 2011

Я думаю, вам нужен диалог QuickAction

Как создать диалоговое окно QuickAction в Android

0 голосов
/ 28 апреля 2011
Notes:
Create One popuplayout.xml file
and parent LinearLayout name give popup_menu_root
and three button name is popup_menu_button1,popup_menu_button2,popup_menu_button3

create main.xml file and put one button

Create MainActivity.java
    setContentView(R.layout.main.xml);

then button click event this code write

ИЛИ ЖЕ

And This Code Write in Your Click Event Then Point Position Set X And Y to last Line Of Code.


// get the instance of the LayoutInflater
                LayoutInflater inflater = (LayoutInflater) Popup.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                // inflate our view from the corresponding XML file
                View layout = inflater.inflate(R.layout.popuplayout,(ViewGroup) findViewById(R.id.popup_menu_root));
                // create a 100px width and 200px height popup window
                final PopupWindow pw = new PopupWindow(layout, 200, 200, false);

                pw.showAtLocation(layout, Gravity.NO_GRAVITY, 100, 250);
                // set actions to buttons we have in our popup
                Button button1 = (Button) layout
                        .findViewById(R.id.popup_menu_button1);
                button1.setOnClickListener(new OnClickListener() {
                    public void onClick(View vv) {
                        // close the popup
                        pw.dismiss();
                    }
                });
                Button button2 = (Button) layout
                        .findViewById(R.id.popup_menu_button2);
                button2.setOnClickListener(new OnClickListener() {
                    public void onClick(View vv) {
                        Toast.makeText(Popup.this, "Hello", Toast.LENGTH_LONG)
                                .show();
                    }
                });
                Button button3 = (Button) layout
                        .findViewById(R.id.popup_menu_button3);
                button3.setOnClickListener(new OnClickListener() {
                    public void onClick(View vv) {
                        finish();
                    }
                });
                // finally show the popup in the center of the window or any position
                // pw.showAtLocation(layout, Gravity.CENTER, 0, 0);
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...