I want to realize a custom popup menu like Twitter in Android for example with item and picture but I don't know what's the component used for that.
In Material Design website, google present this solution. So I think, there is a native solution to achieve this.
I tried with Popup menu, but I can't find how to customize the layout of this view like that.
I have same issue.but finally i found at my own solution that i am sharing you my code. Hope that will help you.
There's a widget called
PopupMenu
which is basically a menu anchored to a specific view. One drawback is that it doesn't display icons by default.However, you can use reflection and call
setForceShowIcon
to reveal them. The code that you need is:Since a
PopupMenu
is anchored to a specific view, yourActionBar
item has anactionLayout
attribute. That layout (action_item.xml
) can be as simple as:ActionBar
menu style that contains your item with the above layoutYour
popup_menu.xml
, the layout you'll inflate for yourPopupMenu
And finally code to perform the inflation when an
ActionBar
item is clickedNote, that to get that multi-line text in a menu, you'd need to use an
actionLayout
for your popup menu items too.This code is working in my app.
Try this :-
You can go through the tutorial from these different providers
http://developer.android.com/guide/topics/ui/actionbar.html
http://www.vogella.com/tutorials/AndroidActionBar/article.html
http://www.androidhive.info/2013/11/android-working-with-action-bar/
All of them have great examples and source code to help you out
Hope this help you :)
you can use a ListPopupWindow, submitting your custom adapter, through which you can control the layout of every single row of the
ListPopupWindow
. As for a normalPopupWindow
you have to provide an anchor view and additionally you have to callsetContentWidth
on the instance ofListPopupWindow
, which sets the width of the popup window by the size of its content. It is a small price you have to pay, but for a small dataset is not a big deal. I have this utility method to retrieve the max width of the row:Use a Pop-Up list fragment. The nice thing about fragments is that you can easily animate them (If you don't understand fragments I recommend first reading Fragment Introduction)
If you want complete control over the pop-up content then see Dialog Fragment