I am developing a Harmony application where I want to create a popup dialog with a custom component.
I tried this
Component customComponent = LayoutScatter.getInstance(context)
.parse(ResourceTable.Layout_custom_dialog, null, false);
// I have already made custom component
PopupDialog popupDialog = new PopupDialog(getContext, customComponent);
popupDialog.show();
After running this I only see a White background Box and Custom Component is not visible.
Why new PopupDialog(getContext, customComponent);
is not setting customComponent.
Please check height and width of custom component is properly set.
Or you can assign values when instantiating popup dialog like -
PopupDialog popupDialog = new PopupDialog(getContext(), associated, width, height);
Also, you’ll need to set custom component to popup dialog before show like -
popupDialog.setCustomComponent(component);
Here is an example from the HarmonyOS developer website