本文介绍了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如何创建弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!