请问 关于在fragment使用popupwindow 弹出对话框的问题
请问 ,在fragment的对话框里边,有个button,当点击这个按钮的时候,使用popupwindow弹出对话框。
但是 在 popupWindow.setAnimationStyle(R.style.AnimBottom); 报错 提示是:
AnimBottom cannot be resolved or is not a field
但是 我在 values/styles.xml 文件中已经添加了一下的代码了呀:
<style name="AnimBottom" parent="@android:style/Animation">
<item name="android:windowEnterAnimation">@anim/push_bottom_in</item>
<item name="android:windowExitAnimation">@anim/push_bottom_out</item>
</style>
另外popupWindow.showAtLocation(
XXXXXXXXXX,
Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
里边的 XXXXXXXXXXXXXX 对应的应该怎么设置呢?查到的资料是说是 parent 参数。但是不太明白。这个究竟需要什么数据呢?
麻烦会的朋友帮忙回复下,谢啦
public class informationFragment extends BaseFragment implements OnClickListener{
。。。。。
private void showPopupWindow() {
View view = (RelativeLayout) LayoutInflater.from(getActivity()).inflate(
R.layout.popmenu, null);
TextView photos = (TextView) view
.findViewById(R.id.photo);
TextView cancel = (TextView) view
.findViewById(R.id.cancel);
photos.setOnClickListener(this);
cancel.setOnClickListener(this);
if (popupWindow == null) {
popupWindow = new PopupWindow(this); }
}
popupWindow.setFocusable(true); // 设置PopupWindow可获得焦点
popupWindow.setTouchable(true); // 设置PopupWindow可触摸
popupWindow.setOutsideTouchable(true); // 设置非PopupWindow区域可触摸
popupWindow.setContentView(view);
popupWindow.setWidth(LayoutParams.MATCH_PARENT); // 设置SelectPicPopupWindow弹出窗体的宽
popupWindow.setHeight(250); // 设置SelectPicPopupWindow弹出窗体的高
popupWindow.setAnimationStyle(R.style.AnimBottom); // 设置SelectPicPopupWindow弹出窗体动画效果
ColorDrawable dw = new ColorDrawable(0xb0000000); // 实例化一个ColorDrawable颜色为半透明
popupWindow.setBackgroundDrawable(dw); // 设置SelectPicPopupWindow弹出窗体的背景
popupWindow.showAtLocation(
XXXXXXXXXX,
Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
popupWindow.update();
}