title: How to display selected Item in spinner with custom adapter?
body: <p>I am trying to implement a spinner in my android app with a custom adapter. I am able to populate the spinner with data, but I am not able to select the data and have it display on the spinner. I also want to display a text like 'Select' when the user hasn't clicked on it.
  Here is my custom adapter-</p>
  <pre><code>import android.content.Context;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.TextView;
  
  import androidx.annotation.NonNull;
  import androidx.annotation.Nullable;
  
  import java.util.List;
  
  public class TransactionModeSpinnerAdapter extends ArrayAdapter&lt;TransactionModeDetails&gt; {
  
      LayoutInflater layoutInflater;
  
      public TransactionModeSpinnerAdapter(@NonNull Context context, int resource, @NonNull List&lt;TransactionModeDetails&gt; transactionModeDetails) {
          super(context, resource, transactionModeDetails);
          layoutInflater = LayoutInflater.from(context);
      }
  
      @NonNull
      @Override
      public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
          View rowView = layoutInflater.inflate(R.layout.activity_spinner_transaction, null,true);
  
          TransactionModeDetails transactionMode = getItem(position);
          TextView txnMode_spn = rowView.findViewById(R.id.spntransaction_tv_txnName);
  
          txnMode_spn.setText(transactionMode.getTransactionModeName());
  
          return rowView;
      }
  
      @Override
      public View getDropDownView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
  
          if(convertView == null){
              convertView = layoutInflater.inflate(R.layout.activity_spinner_transaction, parent,false);
          }
  
          TransactionModeDetails transactionMode = getItem(position);
          TextView txnMode_spn = convertView.findViewById(R.id.spntransaction_tv_txnName);
  
          txnMode_spn.setText(transactionMode.getTransactionModeName());
  
          return convertView;
      }
  }
  </code></pre>
  <p>Below is where I am using it-</p>
  <pre><code>public void populateActiveTransactionModes(){
  
          List&lt;TransactionModeDetails&gt; getTransactionModes = dbHandler.getActiveTransactionModes();
  
          transactionModeListAdapter = new TransactionModeSpinnerAdapter(this, R.layout.activity_spinner_transaction, getTransactionModes);
          selectTransactionMode.setAdapter(transactionModeListAdapter);
  
      }
  </code></pre>