0

I have a ListView, at the bottom of the screen, and each row is represented by an image, what I need here is to show a PopupWindow, at the top center part when I click on the row, kind of show some small details about it, I tried this

        image.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                View view               = mInflater.inflate(R.layout.poi_popup_info, null);

                final PopupWindow popupWindow = new PopupWindow(view, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, true);
                popupWindow.setBackgroundDrawable(new BitmapDrawable());
                popupWindow.showAsDropDown(image);

            }
        });

but this shows it on the bottom left corner

thank you all for your time !

TootsieRockNRoll
  • 3,218
  • 2
  • 25
  • 50
  • 1
    The popup will appear depending on the clicked view, if you want to relocate the view on the screen, check this topic: http://stackoverflow.com/questions/7450959/how-to-show-popupwindow-at-special-location – zozelfelfo Jan 06 '14 at 21:04
  • Alternatively, you could use a [DialogFragment instead](http://stackoverflow.com/questions/15165454/should-i-use-a-popupwindow-or-dialogfragment-for-accepting-input) and [customise its position](http://stackoverflow.com/questions/9698410/position-of-dialogfragment-in-android). – Jonik Jan 06 '14 at 21:18

2 Answers2

0

Instead of PopUpWindow, give ListPopupWindow a shot.

http://developer.android.com/reference/android/widget/ListPopupWindow.html

There are lots of hooks for positioning the pop up within/around a listview

Martin
  • 4,711
  • 4
  • 29
  • 37
0

For those who will need this, I ended up using this library, very useful

https://github.com/shardul/Android/tree/master/ChromeStyleHelpPopups

TootsieRockNRoll
  • 3,218
  • 2
  • 25
  • 50