I've seen similar Q&A on this and played around with several variations. I'm trying to update the Spinner text, but nothing happens.
In the onCreate method I have two spinners: 1.) DCAccount2 (XML ID) 2.) NumofPayments(XML ID)
DC Account2 successfully pulls the query data from Firebase database and populates the drop down with the correct values I want to see. But when I select the value I want, nothing happens. The Spinner text is not updated.?.?
Spinner DC_Account_Spr = findViewById(R.id.DCAccount2);
DC_Account_Spr.setOnItemSelectedListener(this);
ArrayAdapter<String> DC_Array_Adapter = new ArrayAdapter<>(getApplicationContext(), android.R.layout.simple_spinner_item, user_debit_acct_DL);
DC_Array_Adapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
DC_Account_Spr.setAdapter(DC_Array_Adapter);
Spinner Num_Pymts_Spr = findViewById(R.id.NumofPayments);
Num_Pymts_Spr.setOnItemSelectedListener(this);
ArrayAdapter<CharSequence> Num_Pymts_adapter = ArrayAdapter.createFromResource(this, R.array.Num_Payments, com.google.android.material.R.layout.support_simple_spinner_dropdown_item);
Num_Pymts_adapter.setDropDownViewResource(com.google.android.material.R.layout.support_simple_spinner_dropdown_item);
Num_Pymts_Spr.setAdapter(Num_Pymts_adapter);
Other relevant methods:
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long l) {
switch(parent.getId()) {
case (R.id.DCAccount2):
//This is where I think I am not capturing the selected item properly
String Account_Selected_Str = parent.getItemAtPosition(position).toString();
Toast.makeText(getApplicationContext(), Account_Selected_Str, Toast.LENGTH_LONG).show();
case (R.id.NumofPayments):
String Num_Payments_Str = parent.getItemAtPosition(position).toString();
Toast.makeText(getApplicationContext(), Num_Payments_Str, Toast.LENGTH_LONG).show();
}
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
return;
}
I've tried using setSelection and several variables, but still no luck