0

I want to set the Popup Menu inside the LinearLayout.

This is my code.

for(int i=0;i<ev.size();i++)
                {
                    LinearLayout rl1 = new LinearLayout(getActivity());
                    rl1.setOrientation(LinearLayout.VERTICAL);
                    pum1 = new PopupMenu(getActivity(), view);
                    Event ebn=ev.get(i);
                    CalEvent cal = CalEvent.getCalEvent(ebn.getDescription());
                    pum.getMenu().add(Menu.NONE,ebn.getColor(),Menu.NONE,ebn.getTitle());
                    pum.getMenu().add(Menu.NONE,ebn.getColor(),Menu.NONE,cal.event_start);
                    rl1.addView(pum);
                }   

I'am facing this error- "The method addView(View) in the type ViewGroup is not applicable for the arguments (PopupMenu)". Please do help me

  • why you adding popup menu inside LinearLayout ? – Haresh Chhelana Nov 04 '14 at 06:29
  • @HareshChhelana I want to set border and color for the popup menu. So just i tried to add that inside the layout and i planned to set the border and color for the layout. Because am having two data in the popup menu and for every iteration its fetching the title and eventstart. So i want to differentiate that by giving background border and color for every pair. – user3663600 Nov 04 '14 at 06:33
  • addView() only accept ViewGroup base parameter and popup menu is not ViewGroup base so it will not acceptable. – Haresh Chhelana Nov 04 '14 at 06:38
  • @HareshChhelana So Is this any other way to set background border and color for the popup? – user3663600 Nov 04 '14 at 06:42

2 Answers2

0

I think you want to open pop up menu at every data.

in this case you have to make custom listview in which you'll make an adapter class and in that adapter class you can set popup menu at every view.

Vivek Shah
  • 380
  • 2
  • 8
  • No. Actually I have a calendar. I'am creating events for the particular date. If i create multiple events for particular date then i want to display it like pair of title and event start time.So When i click the particular date then popup will open and it will show the list of pair. Just i want to differenciate each pair by giving background border and color. – user3663600 Nov 04 '14 at 06:41
  • so still no need to add this linear layout. you are doing wrong this , you adding view one by one in same object of linear layout , so it will not work. you have to make custom xml that contains linear layout and then by creating that custom xml.make an adapter class and you can do it all the functionality you want. i hope you will get help by this answer. – Vivek Shah Nov 04 '14 at 06:47
0

If you want to create layout like calendar you should use GridLayout with custom adapter where use set your popupMenu. Here is the example: https://stackoverflow.com/a/26545481/3864698

Actually you can use this: https://github.com/roomorama/Caldroid.

Community
  • 1
  • 1
QArea
  • 4,955
  • 1
  • 12
  • 22