I have a page that has layout like the following:
<EditText android:id="@+id/code"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/manualTitle"
android:inputType="number|phone"
android:maxLength="20"
android:singleLine="true"/>
<Spinner android:id="@+id/companySpinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/code"
android:visibility="gone"/>
<Button
android:id="@+id/returnButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/code"
android:layout_alignParentRight="true"
android:layout_marginTop="5sp"
android:layout_marginLeft="8sp"
android:text="@string/button_goback"/>
<Button
android:id="@+id/saveButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/returnButton"
android:layout_alignBaseline="@id/returnButton"
android:text="@string/button_save"/>
Initially the spinner's visibility is gone. First I want to make it visible if users input numbers(0 - 9) to the EditText. Secondly I would like to populate the spinner with values depending on the length of value that users typed into the EditText.
How should I do that? I tried setting an onKey listener for the EditText, but did not achieve the result I want. Am I doing that right? Or should I try listeners other than that?
Any hint or clue or direction is appreciated. Thanks in advance.