有人可以告诉我们如何在Android中的点击位置放置对话框或弹出窗口吗?
答案 0 :(得分:2)
我认为你需要一个QuickAction对话
答案 1 :(得分:0)
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);