android Setting style to programmatically created spinner
<p>I have a spinner which is created programmatically like this:</p>

<pre><code>spinnerLogger = new Spinner(context);
    spinnerLogger.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    SpinnerAdapter spinnerAdapter = new ArrayAdapter&lt;&gt;(context, android.R.layout.simple_spinner_dropdown_item, spinnerNames);
    spinnerLogger.setAdapter(spinnerAdapter);
</code></pre>

<p>in my code I also use xml created spinners which use a style to make sure the user understands they are spinners:</p>

<pre><code>&lt;Spinner
        android:layout_width="90dp"
        android:layout_height="wrap_content"
        android:id="@+id/spinnerHour"
        android:spinnerMode="dropdown"
        style="@style/Widget.AppCompat.Spinner.Underlined" /&gt;
</code></pre>

<p>I want to apply the <code>Widget.AppCompat.Spinner.Underlined</code> style to the programmatically created spinner but can't seem to find how I can achieve this.</p>

<p>I tried by creating an xml containing only a spinner with the right style (xml's name is spinner_underlined and it's located in the layout folder):</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
    &lt;Spinner android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/spinner"
    xmlns:android="http://schemas.android.com/apk/res/android"
    style="@style/Widget.AppCompat.Spinner.Underlined"/&gt;
</code></pre>

<p>when i try to apply this using </p>

<pre><code>SpinnerAdapter spinnerAdapter = new ArrayAdapter&lt;&gt;(context, android.R.layout.spinner_underlined, spinnerNames);
</code></pre>

<p>it gives me a <code>cannot resolve symbol 'spinner_underlined'</code> error</p>