余雪 2013-08-02 09:16 采纳率: 0%
浏览 12812

listview 获取item坐标

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; 
                   }
  • 写回答

1条回答 默认 最新

  • 余雪 2013-08-03 02:07
    关注

    本人以解决

    ()  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的高度乘(当前游标-顶部游标)

    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?