I should create a custom popup menu with a custom lines, which is why I created a arraylist with custom objects because each line must include a title and a subtitle. when I have to put these items in the popup I get this error:
The type of the expression must be an array type but it resolved to
ArrayList<PopupItem>
My code:
navMenuOverflowTitles =new String[]{"Text","Dashboard","Settings", "Order","Filter"};
navMenuOverflowSubTitles = new String[]{"standard","Recently", "","",""};
mPopupList = new ArrayList<PopupItem>();
mPopupList.add(new PopupItem(1,navMenuOverflowTitles[0], navMenuOverflowSubTitles[0], "item1"));
mPopupList.add(new PopupItem(2,navMenuOverflowTitles[1], navMenuOverflowSubTitles[1], "item2"));
mPopupList.add(new PopupItem(3,navMenuOverflowTitles[2], navMenuOverflowSubTitles[2], "item3"));
mPopupList.add(new PopupItem(4,navMenuOverflowTitles[3], navMenuOverflowSubTitles[3], "item4"));
mPopupList.add(new PopupItem(5,navMenuOverflowTitles[4], navMenuOverflowSubTitles[4], "item5"));
View menuItemView = findViewById(R.id.menu_overflow);
popupMenu = new PopupMenu(this, menuItemView);
popupMenu.getMenu().add(Menu.NONE, 1, Menu.NONE, mPopupList[0] );//the error is here
in PopupItem.java
public class PopupItem
{
private int itemId;
private String subtitleText;
private String titleText;
private String tag;
public PopupItem( int itemId, String title, String subtitle, String tag) {
this.itemId=itemId;
this.subtitleText=subtitle;
this.titleText=title;
this.tag = tag;
}
}
In mainActivity.java