Using the List Screenlet

You can now use your new list Screenlet the same way you use any other Screenlet:

  1. Insert the Screenlet’s XML in the layout of the activity or fragment you want to use the Screenlet in. For example, here’s Bookmark List Screenlet’s XML:


    Note that to set a comparator, you must use its fully qualified class name. For example, to use the Bookmarks portlet’s EntryURLComparator, set app:comparator in the Screenlet XML as follows:

  2. Implement the Screenlet’s listener in the activity or fragment class. If your list Screenlet doesn’t have a custom listener, then you can do this by implementing BaseListListener parameterized with your model class. For example:

     public class YourListActivity extends AppCompatActivity 
         implements BaseListListener<YourModelClass> {...

    If you created a custom listener for your list Screenlet, however, then your activity or fragment must implement it instead. For example, recall that the example Bookmark List Screenlet’s listener is BookmarkListListener. To use this Screenlet, you must therefore implement this listener in the class of the activity or fragment that you want to use the Screenlet in. For example:

     public class ListBookmarksActivity extends AppCompatActivity 
         implements BookmarkListListener {...

    See the full example of this here in GitHub.

Well done! Now you know how to create list Screenlets.

Using Screenlets in Android Apps

« Creating the Screenlet ClassCreating Android Views »
Was this article helpful?
0 out of 0 found this helpful