I am trying to make a popup window appear above/below an item that is clicked inside of a ListView. However, the problem is that the View that is coming in from the OnItemClick
Try this and see if it works..
private void setListViewHeightBasedOnChildren(ListView listView) {
ListAdapter listAdapter = listView.getAdapter();
if (listAdapter == null) {
// pre-condition
return;
}
int totalHeight = 0;
int desiredWidth = MeasureSpec.makeMeasureSpec(listView.getWidth(), MeasureSpec.AT_MOST);
for (int i = 0; i < listAdapter.getCount(); i++) {
View listItem = listAdapter.getView(i, null, listView);
listItem.measure(desiredWidth, MeasureSpec.UNSPECIFIED);
totalHeight += listItem.getMeasuredHeight();
}
}
//here listItem.getMeasuredHeight() will get u the height of each list item...U can get ur y position by height*clickedPosition