Full Views

A Full View has a unique Screenlet class, a View class, and layout XML file. It’s standalone and doesn’t inherit from any View. You should create a Full View if there’s no other View that you can extend to meet your needs or if your Screenlet’s behavior can only be augmented by customizing its listeners or calling custom Interactors. To create a Full View, you must create its Screenlet class, View class, and layout XML file. The example Full View here for the Login Screenlet presents a single EditText component for the user name. For the password, it uses Secure.ANDROID_ID. The Screens Test App uses this Full View.

You can follow these steps to create a Full View:

  1. Create a new layout XML file and build your UI in it. A good way to start building your UI is to duplicate another View’s layout XML file and use it as a template. Name your layout XML file after the View’s Screenlet and intended use case. Name its root element after the fully-qualified class name of your custom View (you’ll create this next).

    The Test App’s Full View layout XML file for the Login Screenlet is called login_full.xml. It specifies EditText and Button elements copied from the LongScreenlet’s Default View file login_default.xml.

    <?xml version="1.0" encoding="utf-8"?>
    <com.your.package.LoginFullView
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
    
    <EditText
            android:id="@+id/liferay_login"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="20dp"
            android:hint="Email Address"
            android:inputType="textEmailAddress"/>
    
    <Button
            android:id="@+id/liferay_login_button"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Sign In"/>
    
    </com.your.package.LoginFullView>
    
  2. Create a new custom View class named after the layout’s root element. The tutorial on creating Android Screenlets explains how to create a View class. Note that you don’t have to extend a View class to implement a View Model interface, but you might want to for convenience. The custom View class LoginFullView, for example, implements the LoginViewModel interface by extending the Default LoginView class. To return the ANDROID_ID, the LoginFullView custom View class overrides the getPassword() method.

  3. Create a new Screenlet class that inherits the base Screenlet class. This new class is where you can add custom behavior to the listeners or call custom Interactors. The Screenlet class LoginFullScreenlet, for example, extends LoginScreenlet and overrides the onUserAction method to log Interactor calls.

  4. Insert your View’s Screenlet in any of your activities or fragments, using your new layout’s name as the liferay:layoutId attribute’s value. For example, to use the new login_password layout, insert LoginScreenlet in an activity or fragment, and set liferay:layoutId="@layout/login_password".

The Westeros View Set’s full view for the Sign Up Screenlet uses a custom Screenlet class to add a new listener. The custom Screenlet class also adds a new user action that calls the base Interactor SignUpInteractor.

Themed Views

Child Views

Extended Views

Packaging Your Views

« Extended ViewsPackaging Your Views »
Este artigo foi útil?
Utilizadores que acharam útil: 0 de 0