i want to use Masked EditText for edit text cart number but my code is error and i do not understand whats problem please help me
my error:
Caused by: android.view.InflateException: Binary XML file line #142: Binary XML file line #142: Error inflating class com.example.maskedlib.MaskedEditText Caused by: android.view.InflateException: Binary XML file line #142: Error inflating class com.example.maskedlib.MaskedEditText
my code xml:
<com.example.maskedlib.MaskedEditText
android:id="@+id/edt_cart_number"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_marginStart="2dp"
android:layout_marginEnd="-2dp"
android:layout_toEndOf="@id/ibutton_mic"
android:background="@null"
app:mask="####-####-####-####"
android:fontFamily="@font/iswebmedium"
android:inputType="phone"
android:hint="@string/txt_cart"
android:textAlignment="center"
android:textColorHint="@color/color_input_cart"
android:textSize="15sp" />
there is 2 nice tutorial on these link:
https://github.com/egslava/edittext-mask
https://medium.com/@diegoy_kuri/masks-in-android-edit-text-fields-33a2fd47f1af
You have to create a class for the mask because the attribute "app:mask" dont work like this (like android:fontFamily sometimes).
Hope these tuto will help you !
@gabriel
i use this library but i have error
android.view.InflateException: Binary XML file line #142: Binary XML file line #142: Error inflating class br.com.sapereaude.maskedEditText.MaskedEditText
my xml code:
<br.com.sapereaude.maskedEditText.MaskedEditText
android:id="@+id/edt_cart_number"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_marginStart="2dp"
android:layout_marginEnd="-2dp"
android:layout_toEndOf="@id/ibutton_mic_cart_number"
android:background="@null"
android:fontFamily="@font/iswebmedium"
android:hint="شماره کارت"
android:inputType="phone"
android:textAlignment="center"
android:textColorHint="@color/color_input_cart"
android:textSize="15sp"
android:typeface="monospace"
app:keep_hint="true"
mask:allowed_chars="1234567890"
mask:mask="####-####-####-####" />
my activity code:
edt_cart_number = findViewById(R.id.edt_cart_number); edt_cart_number.getRawText() String a = MaskedEditText edt_cart_number;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.