i want to show a custom popup menu when user click on a floating icon
the float icon create with an service and i have no activity
this is my floating icon c
This error happens when you are trying to show popUpWindow too early ,to fix it, give Id to main layout as main_layout and use below code
Java:
findViewById(R.id.main_layout).post(new Runnable() {
public void run() {
popupWindow.showAtLocation(findViewById(R.id.main_layout), Gravity.CENTER, 0, 0);
}
});
Kotlin:
main_layout.post {
popupWindow?.showAtLocation(main_layout, Gravity.CENTER, 0, 0)
}
Credit to @kordzik