Menu

Create the layout

This section describes how to create the app layout.

Create the buttons and Textview

This app contains 5 buttons.

  • ToggleAdminbtn – prompts the user to activate/deactivate device administrator for the app.
  • ActivateLicencebtn –activates the Knox ELM licence key.
  • EnterProKioskbtn–activates ProKiosk Mode.
  • GetProKioskStatebtn–gives the state of device, ProKiosk or not.
  • ExitProKioskbtn–deactivates ProKiosk Mode.

Open activity_main.xml and insert the following xml mark up. This creates your screen layout.

NOTE – to resolve the @stringerrors, copy these 2 files from the sample app into your project.

  • background.xml:KnoxSdkSample\app\src\main\res\drawable\Background
  • strings.xml: KnoxSdkSample\app\src\main\res\values\strings
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
			xmlns:tools="http://schemas.android.com/tools"
			android:id="@+id/mainpage"
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			tools:context="com.samsung.knox.example.prokioskmode.MainActivity">

			<TextView
			android:id="@+id/logview_id"
			android:gravity="bottom"
			android:layout_width="320dp"
			android:layout_height="230dp"
			android:textColor="#3F51B5"
			android:background="@drawable/background"
			android:scrollbars="vertical"
			android:paddingLeft="10dp"
			android:layout_marginTop="22dp"
			android:layout_alignParentTop="true"
			android:layout_centerHorizontal="true" />

			<ScrollView
			android:id="@+id/scrollView"
			android:layout_marginTop="10dp"
			android:layout_below="@id/logview_id"
			android:layout_width="match_parent"
			android:layout_height="wrap_content">

			<RelativeLayout
			android:padding="10dp"
			android:layout_width="match_parent"
			android:layout_height="wrap_content">


			<Button
			android:id="@+id/ToggleAdminbtn"
			android:layout_width="200dp"
			android:layout_height="wrap_content"
			android:layout_centerHorizontal="true"
			android:text="@string/activate_admin" />

			<Button
			android:id="@+id/ActivateLicensebtn"
			android:layout_width="200dp"
			android:layout_height="wrap_content"
			android:layout_alignStart="@+id/ToggleAdminbtn"
			android:layout_below="@+id/ToggleAdminbtn"
			android:text="@string/activate_license" />

			<Button
			android:id="@+id/EnterProKioskbtn"
			android:layout_width="200dp"
			android:layout_height="wrap_content"
			android:layout_below="@+id/ActivateLicensebtn"
			android:layout_alignStart="@+id/ActivateLicensebtn"
			android:text="@string/enter_prokiosk"/>

			<Button
			android:id="@+id/GetProKioskStatebtn"
			android:layout_width="200dp"
			android:layout_height="wrap_content"
			android:layout_below="@+id/EnterProKioskbtn"
			android:layout_alignStart="@+id/ActivateLicensebtn"
			android:text="@string/get_prokiosk_state"/>

			<Button
			android:id="@+id/ExitProKioskbtn"
			android:layout_width="200dp"
			android:layout_height="wrap_content"
			android:layout_below="@+id/GetProKioskStatebtn"
			android:layout_alignStart="@+id/ActivateLicensebtn"
			android:text="@string/exit_prokiosk" />
			</RelativeLayout>
			</ScrollView>
			</RelativeLayout>

		

You now see 5 buttons in the middle of the screen. ACTIVATE ADMIN, ACTIVATE LICENCE, ENTER PROKIOSK MODE ,GET PROKIOSK STATE andEXIT PROKIOSK MODE. You will later assign methods to these buttons to control their respective actions. There is also a TextView at the top of the screen that will display any log messages.

For detailed information on creating Android layouts, see Google's page on how to Build a Simple User Interface.

Tutorial Progress

You are 2/7 done! Go to the next step.