• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Help with spinner

dmobb

Lurker
Apr 11, 2011
3
0
I am trying to use a spinner in my app as a drop down menu.

Here is the xml code:
<Spinner
android:id="@+id/fromSpinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:spinnerMode="dropdown"
android:entries="@array/from_array" />

Here is the Java code:

Spinner fromSpinner = (Spinner) findViewById(R.id.fromSpinner);
Spinner toSpinner = (Spinner) findViewById(R.id.toSpinner);
ArrayAdapter<String> toAdapter = new ArrayAdapter<String>(this, R.id.toSpinner, R.array.to_array);
toSpinner.setAdapter(toAdapter);
ArrayAdapter<String> fromAdapter = new ArrayAdapter<String>(this, R.id.fromSpinner, R.array.from_array);
fromSpinner.setAdapter(fromAdapter);
String toCurrency = (String) toSpinner.getSelectedItem();
String fromCurrency = (String) fromSpinner.getSelectedItem();

I'm not sure what the adapters do but I think I need them. Anyway toCurrency and fromCurrency aren't getting the values they are supposed to get. Anyone know what I am doing wrong. I am a complete noob so it may be something really dumb.

In case it helps the entire app source is at https://github.com/Dmobbjr/CurrencyCalculator
This is the first app I am trying to make without a tutorial. I was able to get everything working except this.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones