Tutorial 15 - How to create Single choice dialog

What you will learn in this Tutorial

How to create SIGLE_CHOICE_DIALOG

Download Source Code - Tutorials - Source for this tutorial is in appemble-tutorial-single-sel-ctrl
Reference SINGLE_CHOICE_DIALOG control
Other pickers: CHECKBOX, DATETIMEPICKER, NUMBER_PICKER, SINGLE_CHOICE_PICKER

Introduction

SINGLE_CHOICE_DIALOG control allows a user to select one of many values. It is essentially a group of radio buttons / values. The look and feel is native to the OS.

Android iOS
../_images/single_choice_dialog.png ../_images/ios_single_choice_dialog.png

How to create SIGLE_CHOICE_DIALOG

The specific attributes that define SINGLE_CHOICE_DIALOG are

Attribute Description / Value Mandatory
type SINGLE_CHOICE_DIALOG Yes
title Defines title of SINGLE_CHOICE_DIALOG. For example title=”Shopping list category” Yes
display_values Comma separated values to be displayed in the selection list. For example display_values=”Grocery, Clothes, Stationary” Yes
storage_values Comma separated values to be stored. If provided, the number of storage_values MUST match the number of display values. They give the flexibility to store codes for user selection. No
values_query display_values and storage_values can be fetched from the local database using a query. The first column MUST be display_values. The 2nd column for storage_values is optional. For example values_query=”select * from categories”. No
default_value Default Value is storage_value (if present) or display_value No

In the tutorial single-sel-ctrl, the code below allows the user to select a category.

<control type="SINGLE_CHOICE_DIALOG" x="35" y="14" width="40" height="8" appearance_name="grey_button" data_type="VARCHAR"
                     field_name="category" default_value="Select Category" title="Shopping List Category"
                     display_values="Grocery, Office Supplies" storage_values="Grocery, Office Supplies"/>

Try a variation by getting the values from categories table.

<control type="SINGLE_CHOICE_DIALOG" x="35" y="14" width="40" height="8" appearance_name="grey_button" data_type="VARCHAR"
                     field_name="category" default_value="Select Category" title="Shopping List Category"
                     values_query="select * from categories"/>

Run the appemble-tutorial-single-sel-ctrl. If you have not downloaded tutorial source code, click on Download Source Code - Tutorials

Android - Right click on appemble-tutorial-single-sel-ctrl and click on Run as Android application.

iOS - Select scheme appemble-tutorial-single-sel-ctrl and iPhone/iPad x.x simulator. Click on Product -> Run.