How to show a ListFragment on top right screen when user click a button
I want to show a ListFragment when user click a button on the top right corner. When user select a item in this ListFragment or just touch the screen outside the ListFragment, the ListFragment should be disappeared.
Just like below
screen shot image (i don't have rights to post an image, so I have uploaded it to my blog)
I tried to use DialogFragment to wrap the ListFragment, but I find no way to set the dialog's position, it always shows in the center, I need to display the ListFragment on the top right of screen.
And I also tried to use PopupWindow, but I don't know how to set a ListFragment as popupwindows' contentview.
So,开发者_开发技巧 my questions are:
- how to show a ListFragment when user click a button, this ListFragment should be shown at top right corner.
- how to hide this ListFragment when user select a item of this ListFragment or touch the screen outside the ListFragment.
Sorry for my poor English :)
Place all your view in a RelativeLayout and set these attributes to your ListView:
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
Also change the size of your ListView programmatically on any event you like.
精彩评论