listview 获取item坐标
当listview高度是固定的,上拉item后,就很难计算拉动后的item坐标了
private void initPop(View v,int position){
View popupWindow_view =inflater.inflate(R.layout.login, null);
PopupWindow popupWindow = new PopupWindow(popupWindow_view, getWindowManager().getDefaultDisplay().getWidth() 3/5, 152, true);
popupWindow.setTouchable(true);
popupWindow.setBackgroundDrawable(new BitmapDrawable()); //
popupWindow.setFocusable(true);
TextView text1= (TextView)popupWindow_view.findViewById(R.id.text1);
TextView text2= (TextView)popupWindow_view.findViewById(R.id.text2);
text1.setText(list1.get(index).get(position).get("text1").toString());
text2.setText(list1.get(index).get(position).get("text2").toString());
popupWindow.showAsDropDown (edit1,getWindowManager().getDefaultDisplay().getWidth() /5,v.getHeight()(position%11+1));//问题主要在这一句,目的在item下弹出popupwindow,可是当拖地item后,再长按就不能计算正确出item的位置了,各位有什么好的计算方法望赐教!谢谢了。
}
public void pop(View v) {//按钮1事件
popup();
}
public boolean onItemLongClick(AdapterView<?> arg0, View arg1,int arg2,long arg3) {
initPop(arg1,arg2);
click=arg2;
adapter.notifyDataSetChanged();
return true;
}
本人以解决
() popupWindow.showAsDropDown (edit1,getWindowManager().getDefaultDisplay().getWidth() /5,(v.getHeight()+1)*(position-listView.getFirstVisiblePosition() +1/4));//位于et下面
关键代码
(v.getHeight()+1)*(position-listView.getFirstVisiblePosition() +1/4)
item的高度乘(当前游标-顶部游标)