From wiki.ginstr.com
Revision as of 14:20, 18 October 2016 by Bojan (talk | contribs) (Text read only option)
Jump to: navigation, search

Text

Widget is used for textual input of data by user. Value will be stored as datatype TEXT.

Widget id:

see variants

Back to ginstr app composer reference

Predefined user data

PreLoaded

AutoLoaded data which is known:

  • ${pageName} - name of the page to which widgets are added

Prompts

User enters this data when widget is dropped to screen:

  • ${widgetName} - name of the widget user added to the screen
  • ${hintText} - hint text

Widget references

If widget is added via app composer autogenerated ids will be created according to table below.

Control Attribute Value
GnTextView android:id @+id/${pageName}${widgetName}Label
GnTextView android:text @string/${pageName}_${widgetName}
GnEditText android:id @+id/${pageName}${widgetName}Input
GnEditText gn:s_hint @string/${pageName}_${widgetName}Hint
GnTextView gn:style @style/${widgetID}Label
GnEditText gn:style @style/${widgetID}Input

Code snippets

Common widget code

<com.ginstr.widgets.GnTextView
    android:id="@+id/${pageName}${widgetName}Label"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/${pageName}_${widgetName}"
    gn:style="@style/${widgetID}Label"/>

<com.ginstr.widgets.GnEditText
    android:id="@+id/${pageName}${widgetName}Input"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    gn:s_hint="@string/${pageName}_${widgetName}Hint"
    gn:dataType="text"
    gn:style="@style/${widgetID}Input"/>


strings.xml

Lines to be added for EN language

<string name="${pageName}_${widgetName}">${widgetName}</string>
<string name="${pageName}_${widgetName}Hint">${hintText}</string>


Lines to be added for DE language

<string name="${pageName}_${widgetName}">${widgetName}</string>
<string name="${pageName}_${widgetName}Hint">${hintText}</string>




Variants



Text editable variant

Widget id:

textEditable
Widget code
    gn:s_sourceType="input"




Nfc variant

Widget id:

nfc
Widget code
    gn:s_sourceType="nfc"




Barcode variant

Widget id:

qr
Widget code
    gn:s_sourceType="qr"



Options

Options can be used in combination with variants. i.e. field can be editableText with option required



Text read only option

Widget id:

textReadOnly

Read only is property of widget. When checked data can not be input into widget by user.

Widget code
    gn:s_sourceType="input"
    gn:focusable="false"
    android:background="#00000000"



Text required option

Widget id:

Id of variant is used

Required is property of widget.

autogenerated content
Widget code
    gn:act_validate="[name:RequiredValidator],[message=@string/${pageName}_${widgetName}Required]"

app composer will use from $defaultApp:

    gn:act_validate="[name:RequiredValidator],[message=@string/defaultRequiredValidator]"

strings.xml

<string name="defaultRequiredValidator">entering the %1$s is required</string>

app composer will produce: strings.xml

<string name="${pageName}_${widgetName}Required">entering the ${widgetName} is required</string>
user changed autogenerated content
Widget code
    gn:act_validate="[name:RequiredValidator],[message=@string/${pageName}_${widgetName}Required]"

strings.xml

<string name="${pageName}_${widgetName}Required">${userInput}</string>