What android:inputType should I use for entering an IP Address and hostname? What android:inputType should I use for entering an IP Address and hostname? java java

What android:inputType should I use for entering an IP Address and hostname?


Try using android:inputType="number", but also set android:digits="0123456789.". Works for me.


If you use inputType="phone" you gain access to a cut down keyboard containing Numbers and a Period character - this doesn't restrict the input with regards to the amount of Periods you can enter.

Please see this answer for validation while being entered.


This works perfectly keyboard with numbers and decimal by adding android:inputType="number|numberDecimal" and android:digits="0123456789."

Example

 <EditText    android:id="@+id/ip_address"    android:inputType="number|numberDecimal"    android:digits="0123456789."    android:layout_width="match_parent"    android:layout_height="wrap_content"/>