Android如何创建弹出窗口

Android how to create popup window(Android如何创建弹出窗口)
本文介绍了Android如何创建弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个带有按钮的弹出窗口和一个关闭弹出窗口的按钮.我找到了一些教程,但我不知道如何实现.

I need to create a popup window with buttons and a button that will close the popup. I found some tutorials but I couldn't find out how to do the implementation.

我想要做什么:单击一个操作按钮并显示弹出窗口,当我单击关闭按钮时,弹出窗口必须关闭.

What I want to do: Click an action button and the popup shows and when I click the the close button the popup window must close.

教程中有一个onCreate方法,我不明白它是怎么调用的.

There were an onCreate method in the tuorials and I didn't understand how is it called.

谁能给出一个弹出实现的例子或一个好的教程的链接?谢谢!

Can somebody give an example of an popup implementation or a link to a good tutorial? Thank you!

推荐答案

private void showPopup(){
    Button btn_closepopup=(Button)layout.findViewById(R.id.btn_closePoppup);
    pwindo=new PopupWindow(layout,480,500,true);
    pwindo.showAtLocation(layout, Gravity.CENTER, 0, 40);
    chartContainer1.addView(mChart);
    btn_closepopup.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            pwindo.dismiss();
        }
    });
}

这篇关于Android如何创建弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)
iOS: Send multiple actions to a bar button(IOS:向一个栏按钮发送多个动作)