Having a problem loading an array into a spinner that is located on a different view. The array is defined properly in arrays.xml with a name of beerstyles. The beerstylespinner is defined as the id of a spinner in carbonationcalculator_view.xml
. This works when the code is in the main java class but not the additional carbonationcalculator class. Everything works with the exception of the spinner not being populated with the array.
Here is the code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.carbonationcalculator_view);
Spinner s = (Spinner) findViewById(R.id.beerstylespinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.beerstyles, R.layout.carbonationcalculator_view);
adapter.setDropDownViewResource(R.layout.carbonationcalculator_view);
s.setAdapter(adapter);
}