的Andr​​oid如何创建弹出窗口 [英] Android how to create popup window

查看:109
本文介绍了的Andr​​oid如何创建弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建带有按钮的弹出窗口和一个按钮,将关闭弹出。我发现了一些教程,但我找不到了怎么办实施。

我想要做的:点击操作按钮,并在弹出的节目,当我点击关闭按钮的弹出窗口必须关闭

有分别在tuorials的onCreate方法,我不明白怎么叫。

有人可以给出一个弹出实施或一个很好的教程链接的例子吗?谢谢!


解决方案

 私人无效showPopup(){按钮btn_closepopup =(按钮)layout.findViewById(R.id.btn_closePoppup);
pwindo =新PopupWindow(布局,480 500,真正的);
pwindo.showAtLocation(布局,Gravity.CENTER,0,40); chartContainer1.addView(mChart);
                                       btn_closepopup.setOnClickListener(新OnClickListener(){    @覆盖
    公共无效的onClick(查看为arg0){
    // TODO自动生成方法存根
                                            pwindo.dismiss();
    }
    });
}

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.

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();
    }
    });
}

这篇关于的Andr​​oid如何创建弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆