I have a spinner included on my form. Now I need to pass the selected value and include it on my form request. Populating the Spinner is already working, I just need to get the selected value. I am fairly new to Android, so I will greatly appreciate any help or tips you can offer.
Here's the Spinner value:
//this method will execute when we pick an item from the spinner
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
//Setting the values to textviews for a selected item
tvID.setText(getName(position));
}
This is my submit button function:
btnSignup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final String firstname = etFname.getText().toString();
final String lastname = etLname.getText().toString();
final String email = etEmail.getText().toString();
final String phone = etContact.getText().toString();
final String username = etUsername.getText().toString();
final String password = etPassword.getText().toString();
final String department = spinner.getSelectedItem().toString();
//GET the value of spinner and include it here
I will need the spinner value so I can include it on my request:
RegisterRequest registerRequest = new RegisterRequest(firstname, lastname, email, phone, username, password, responseListener);
RequestQueue queue = Volley.newRequestQueue(RegisterActivity.this);
queue.add(registerRequest);
EDIT: I tried the solutions below but I'm getting this error: