popup2.getMenu().setGroupCheckable(R.id.priorityAreazone,true,true);
popup2.getMenu().add(R.id.priorityAreazone,(i),(i),zoneNames.get(i)).setCheckable(true);
I am trying to radio button to popup menu,I am able to add checkbox but unable to add radio button how can i do that.
This works for me.
public void showPopup(View v) {
PopupMenu popup = new PopupMenu(this.getContext(), v, Gravity.RIGHT);
popup.setOnMenuItemClickListener(this);
// popup.inflate(R.menu.hc_popup_check);
// popup.getMenu().findItem(R.id.item1).setChecked(true);
int groupId = 1;
popup.getMenu().add(groupId, 1, 1, "Share").setCheckable(true);
//.setChecked
popup.getMenu().add(groupId, 2, 2, "Comment").setCheckable(true);
popup.show();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.