You can start using Screenlets once you’ve prepared your project to use Liferay Screens. There are plenty of Liferay Screenlets available and they’re described in the Screenlet reference documentation. It is very straightforward to use Screenlets. This tutorial shows you how to insert Screenlets into your android app and configure them. You’ll be a Screenlet master in no time!
First, in Android Studio’s visual layout editor or your favorite editor, open
your app’s layout XML file and insert the Screenlet in your activity or fragment
layout. The following screenshot, for example, shows the Login Screenlet
inserted in an activity’s FrameLayout
.
Next, set the Screenlet’s attributes. If it’s a Liferay Screenlet, refer to the Screenlet reference documentation to learn the Screenlet’s required and supported attributes. This screenshot shows the attributes of the Login Screenlet being set:
To configure your app to listen for events the Screenlet triggers, implement the
Screenlet’s listener interface in your activity or fragment class. Refer to the
Screenlet’s documentation to learn its listener interface. Then register your
activity or fragment as the Screenlet’s listener. The activity class, for
example, in the screenshot below, declares that it implements the
Login Screenlet’s LoginListener
interface, and it registers itself to listen
for the Screenlet’s events.
Make sure to implement all methods required by the Screenlet’s listener interface. For Liferay’s Screenlets, the listener methods are listed in each Screenlet’s reference documentation. That’s all there is to it! Awesome! Now you know how to use Screenlets in your Android apps.
Related Topics
Preparing Android Projects for Liferay Screens