转载自:http://www.eoeandroid.com/viewthread.php?tid=10850&highlight=popup%2Bwindow
public class popWindow extends Activity {
/** Called when the activity is first created. */
Button button_show;
View contentView;
PopupWindow pWindow;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button_show=(Button)findViewById(R.id.show_popwindow);
contentView=View.inflate(popWindow.this, R.layout.pwcontent, null);
contentView.setBackgroundDrawable(getResources().getDrawable(R.drawable.fantasy_pictuer_06));
contentView.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
pWindow.dismiss();
}
});
pWindow=new PopupWindow(contentView);
pWindow.setWindowLayoutMode(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
button_show.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
try {
if(pWindow.isShowing())
{
pWindow.dismiss();
}
pWindow.showAsDropDown(v);
pWindow.setFocusable(true);
} catch (Exception e) {
Toast.makeText(popWindow.this, e.getMessage(), Toast.LENGTH_SHORT);
}
}
});
}
}
分享到:
相关推荐
PopupWindow
实现的功能有弹出的PopupWindow上有EditText能与软键盘并存不冲突,弹出PopupWindow的时候背景自动改变灰度为半透明黑色,消失后背景灰度复原,PopupWindow还能根据自己的实际需求制定自己想要的弹出动画,以及...
android popupwindow 底部灰色背景
PopupWindow之显示顶层对话框代码
android 封装一个通用PopupWindow,避免重复造轮子,简化代码,方便管理。
仿微信右上角弹出PopupWindow的Demo,
popupwindow弹窗实现点击按钮,下方弹出popwindow,并且只是按钮下方有阴影,按钮以及上方没有阴影
Android源码——PopupWindow实现弹出菜单.zip
Android从屏幕底部滑动弹出PopupWindow,有动画效果,类似于sharesdk的分享页面滑动弹出效果。
让popupwindow显示在view的上方并与该view水平居中对齐
popupwindow 遮罩 窗帘式 从上往下 半显示 带动画 漂亮
和大家分享一下用一个PopupWindow来做一个指引蒙板的效果。鉴于网上对于“指引蒙板”的实现例子不是太多(或者是我找不到更多的),而且好像有很多的例子都是用一个Frame布局+Fragment去完成,对于这种做法自己不太...
AS写的PopupWindow demo blog:http://blog.csdn.net/shenyuanqing/article/details/48136639
点击按钮在屏幕下方会出现PopupWindow,PopupWindow中的PickerView可以用来选择时间。
Android PopupWindow与Activity之间的数据传递