View pview = inflater.inflate(R.layout.popup_example,(ViewGroup)findViewById(R.layout.main));
PopupWindow pw = new PopupWindow(pview);
pw.showAtLocation(v, Gravity.LEFT,0,0);
pw.update(8,-70,150,270);
//if onclick written here, it gives null pointer exception.
ImageButton img=(ImageButton)pview.findViewById(R.id.home);
img.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
Intent.....
}
});
PopupWindow的使用
PopupWindow使用详解
最新推荐文章于 2025-01-14 03:38:39 发布
本文详细介绍了如何在Android应用中使用PopupWindow组件创建弹出窗口。包括初始化布局、设置位置及尺寸,以及为弹出窗口中的ImageButton添加点击监听器的具体实现方式。
1万+

被折叠的 条评论
为什么被折叠?



