How to request focus on TextInputLayout programmatically in case of error?
<p>i have five fields in a form and on validation error message and floating labels are working perfectly but in the case of error when I am calling <code>requestFocus()</code> method on a particular <code>TextInputLayout</code> object then it is not getting focussed.</p>

<p>Code Snippet: </p>

<pre><code>                BetterSpinner Spinner_material = (BetterSpinner)rfqItem.findViewById(R.id.Spinner_material);
            if(Spinner_material.getText()!=null &amp;&amp; Spinner_material.getText().toString().length()&gt;0)
            {
                TextInputLayout_category.setError(null);
                TextInputLayout_category.setErrorEnabled(false);
            }
            else
            {
                if(isReporting)
                {
                    TextInputLayout_category.setErrorEnabled(true);
                    TextInputLayout_category.setError(baseActivity.getString(R.string.addrfq_validationerror_material_category));
                    TextInputLayout_category.requestFocus();
                }
                flag=false;
            }
</code></pre>

<p>XML Snippet : </p>

<pre><code>&lt;android.support.design.widget.TextInputLayout
            android:id="@+id/TextInputLayout_category"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"&gt;
            &lt;com.power2sme.android.utilities.customviews.BetterSpinner
                android:id="@+id/Spinner_material"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/addrfq_hint_sku_category"
                android:imeOptions="actionNext"
                android:inputType="textNoSuggestions"
                android:singleLine="true"/&gt;
        &lt;/android.support.design.widget.TextInputLayout&gt;
</code></pre>

<p>BetterSpinner is a third party library and it is derived from AutoCompleteTextView.</p>