Restrict EditText for numeric and capital alphabets input is so easy in android. We just need to add two lines of code in xml file and we are ready.
But why we need to do it?
May be we just want edittext for pan number verification, or may be other use case where we know user must enter all details in capital. The below EditText is capable enough to do it :
<androidx.appcompat.widget.AppCompatEditText android:id="@+id/etInput" style="@style/App_EditText" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="@dimen/margin_extra" android:digits="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" android:text="@={viewModel.currentQuestion.desc}" android:inputType="textCapCharacters" />
Share this content: