title: ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.TextView when setting hint for spinner
body: <p>Am trying to sent hint for my spinner that uses a base adapter to load the spinner items</p>
  
  <p>Below is my spinner adapter</p>
  
  <pre><code>package manu.apps.cartv6.Adapters;
  
  import android.content.Context;
  import android.graphics.Color;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.BaseAdapter;
  import android.widget.TextView;
  
  import java.util.List;
  
  import manu.apps.cartv6.Classes.Category;
  import manu.apps.cartv6.R;
  
  public class CategoryAdapter extends BaseAdapter {
  
      private Context context;
      private List&lt;Category&gt; categoryList;
  
      public CategoryAdapter(Context context, List&lt;Category&gt; categoryList) {
          this.context = context;
          this.categoryList = categoryList;
      }
  
      @Override
      public int getCount() {
          return categoryList.size();
      }
  
      @Override
      public Object getItem(int position) {
          return categoryList.get(position);
      }
  
      @Override
      public long getItemId(int position) {
          return position;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
  
          ViewHolder viewHolder;
  
          if(convertView == null) {
              convertView = LayoutInflater.from(context).inflate(R.layout.layout_spinner_items,parent,false);
              viewHolder = new ViewHolder(convertView);
              convertView.setTag(viewHolder);
          }else {
              viewHolder = (ViewHolder) convertView.getTag();
          }
  
          Category currentCategory = (Category) getItem(position);
  
          viewHolder.categoryName.setText(currentCategory.getCategoryName());
  
  
          return convertView;
      }
  
      private class ViewHolder {
          TextView categoryId, categoryName;
  
          public ViewHolder(View view) {
              categoryName = view.findViewById(R.id.tv_spinner_item_name);
          }
      }
  
      @Override
      public boolean isEnabled(int position) {
          return position != 0;
      }
  
      @Override
      public View getDropDownView(int position, View convertView, ViewGroup parent) {
          View view = super.getDropDownView(position, convertView, parent);
          TextView tv = (TextView) view;
          if(position == 0){
              // Set the hint text color gray
              tv.setTextColor(Color.GRAY);
          }
          else {
              tv.setTextColor(Color.BLACK);
          }
          return view;
      }
  }
  
  </code></pre>
  
  <p>Here is the method i use to set my spinner adapter</p>
  
  <pre><code>
  private void setUpSelectCategorySpinner(List&lt;Category&gt; categoryList) {
          categoryAdapter = new CategoryAdapter(getActivity(), categoryList);
          spnSelectCategory.setAdapter(categoryAdapter);
      }
  
  </code></pre>
  
  <p>Here is my spinner on items selected listener</p>
  
  <pre><code>
  spnSelectCategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
              @Override
              public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position, long id) {
                  category = (Category) parent.getSelectedItem();
  
                  categoryId = category.getId();
                  categoryName = category.getCategoryName();
  
                  String selectedItemText = categoryName;
  
                  // Test on Item Selected
                  //Toast.makeText(getActivity(),"Id: " + categoryId+ "\nCategoryName: " + categoryName , Toast.LENGTH_SHORT).show();
  
                  if(position &gt; 0){
                      // Notify the selected item text
                      Toast.makeText
                              (getActivity(), "Selected : " + selectedItemText, Toast.LENGTH_SHORT)
                              .show();
                  }
              }
  
              @Override
              public void onNothingSelected(AdapterView&lt;?&gt; parent) {
  
              }
          });
  
  </code></pre>
  
  <p>i want the first item that i load in the spinner to be displayed as hint and am getting the following error</p>
  
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
  Process: manu.apps.cartv6, PID: 22404
  java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.TextView
      at manu.apps.cartv6.Adapters.CategoryAdapter.getDropDownView(CategoryAdapter.java:78)
      at androidx.appcompat.widget.AppCompatSpinner$DropDownAdapter.getDropDownView(AppCompatSpinner.java:740)
      at androidx.appcompat.widget.AppCompatSpinner$DropDownAdapter.getView(AppCompatSpinner.java:734)
      at androidx.appcompat.widget.AppCompatSpinner.compatMeasureContentWidth(AppCompatSpinner.java:574)
      at androidx.appcompat.widget.AppCompatSpinner$DropdownPopup.computeContentWidth(AppCompatSpinner.java:1010)
      at androidx.appcompat.widget.AppCompatSpinner$DropdownPopup.show(AppCompatSpinner.java:1037)
      at androidx.appcompat.widget.AppCompatSpinner.showPopup(AppCompatSpinner.java:600)
      at androidx.appcompat.widget.AppCompatSpinner.performClick(AppCompatSpinner.java:444)
      at android.view.View.performClickInternal(View.java:6631)
      at android.view.View.access$3100(View.java:790)
      at android.view.View$PerformClick.run(View.java:26187)
      at android.os.Handler.handleCallback(Handler.java:907)
      at android.os.Handler.dispatchMessage(Handler.java:105)
      at android.os.Looper.loop(Looper.java:216)
      at android.app.ActivityThread.main(ActivityThread.java:7625)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
  </code></pre>
  
  <p>Below is my xml where the spinner is inside a relative layout which is inside a linear layout</p>
  
  <pre><code>
   &lt;RelativeLayout
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:padding="1dp"
                      android:layout_marginEnd="5dp"
                      android:layout_marginStart="5dp"&gt;
  
                      &lt;TextView
                          android:id="@+id/tv_select_category"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:text="@string/select_a_category_with_colon"
                          style="@style/TextAppearance.AppCompat.Body1"
                          android:layout_alignParentStart="true"
                          android:layout_centerInParent="true"
                          android:layout_margin="1dp"/&gt;
  
                      &lt;Spinner
                          android:id="@+id/spn_select_category"
                          android:layout_width="100dp"
                          android:layout_height="wrap_content"
                          android:layout_toEndOf="@+id/tv_select_category"
                          android:layout_alignParentEnd="true"
                          android:layout_centerInParent="true" /&gt;
  
  
                  &lt;/RelativeLayout&gt;
  
  </code></pre>
  
  <p>My Layout Spinner Items</p>
  
  <pre><code>
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:padding="5dp"&gt;
  
      &lt;TextView
          android:id="@+id/tv_spinner_item_name"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Spinner Item Name"
          style="@style/TextAppearance.AppCompat.Small"
          android:layout_margin="5dp"/&gt;
  
  &lt;/LinearLayout&gt;
  
  </code></pre>
  
  <p>Thanks in advance</p>