I’ve created a spinner for my application. This is the code in the main.xml
<Spinner
android:id="@+id/sMenu"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:prompt="@string/base"
/>
and in my main class
String [] base = {"Decimale", "Binaria", "Ottale", "Esadecimale"};
Spinner s1;
s1 = (Spinner) findViewById (R.id.sMenu);
ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.base, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s1.setAdapter(adapter);
The program converts a number in binary, decimal, octal, hexadecimal. I want to associated some events to the spinner. For example, if I select in the spinner binary, in the edit text I can put only binary numbers. In which way I can associate this event to the spinner?
1 Answer