Hello, good evening. In my project I have a spinner
<Spinner
android:id="@+id/spnCategorie"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/categories_array"
android:prompt="@string/categories_prompt" />
This spinner
is responsible for adding the value in the CATEGORIE
column in my database through the InsertProduct.class class.
The categories that populate this spinner
are as follows:
<string-array name="categories_array">
<item>Mantimentos</item>
<item>Açougue</item>
<item>Peixaria</item>
<item>Frios</item>
<item>Hortifruti</item>
<item>Café da Manhã</item>
<item>Higiene</item>
<item>Limpeza</item>
</string-array>
I'm converting the value of spinner
to String
to insert in banco de dados
as follows. ( I do not know if it's the right way. )
Spinner CATEGORIE = (Spinner) findViewById(R.id.spnCategorie);
String stringCATEGORIE = CATEGORIE.getSelectedItem().toString();
...
I have another class ( AlterProduct.class ) responsible for changing the values of the products, I would like the spinner
of the class AlterProduct.class to return the category saved in the database of data.
Ex: My product was inserted into the database with the Frios
category, when the user clicked to change the product, it would return the Frios
value in spinner
of the AlterProduct.class strong>
Att.
Giovani Rodrigo