我使用StickyGridHeaders库来创建类似于Snapfish的网格视图。这是我期望的布局:
这是我的适配器头:
如果我在子视图中显示弹出窗口而不是标题,则弹出窗口会正确显示。这里有什么问题吗?
StickyGridHeadersGridView.setAreHeadersSticky(false);
关闭了我的网格视图的粘性头部。这是我的适配器头:
public View getHeaderView(final int position, View convertView, ViewGroup parent) {
final HeaderViewHolder viewHolder;
if(convertView == null){
convertView = inflater.inflate(R.layout.item_header_gallery, null);
viewHolder = new HeaderViewHolder();
viewHolder.tvImagePrice = (TextView) convertView.findViewById(R.id.tvImagePrice);
viewHolder.btnTouch = (Button) convertView.findViewById(R.id.btnTouch);
convertView.setTag(viewHolder);
}else{
viewHolder = (HeaderViewHolder) convertView.getTag();
}
ImageGroup item = headers.get(position);
viewHolder.tvImagePrice.setText(item.getPriceString());
viewHolder.btnTouch.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int[] location = new int[2];
viewHolder.btnTouch.getLocationOnScreen(location);
// location always is [905,59] for every header item
System.out.println("location = " + location[0] + "," + location[1]);
// show popup on this location:
mPopupWindow.showAtLocation(v, Gravity.NO_GRAVITY, location[0], location[1]);
}
});
return convertView;
}
如果我在子视图中显示弹出窗口而不是标题,则弹出窗口会正确显示。这里有什么问题吗?
View
获取位置:而不是从viewHolder
实例中获取。v.getLocationOnScreen(location);
- myanimal