我在列表视图上有一个按钮,单击该按钮将显示弹出窗口。我已经成功地实现了这一点。但问题是我想在单击的按钮位置显示弹出窗口。
View layout = inflater.inflate(R.layout.popup_layout,null);
pwindo = new PopupWindow(layout, 300, 250, true);
pwindo.showAtLocation(layout, Gravity.NO_GRAVITY, 30, 40);
pwindo.setOutsideTouchable(true);
pwindo.setTouchable(true);
pwindo.setBackgroundDrawable(new BitmapDrawable());
layout.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
pwindo.dismiss();
return false;
}
});
按钮代码
vi = inflater.inflate(R.layout.list_row, null);
vi.findViewById(R.id.statusImage).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
showPopup();//to display popup thats given above
}
});