[英]Masked EditText is not working android studio
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我想使用 Masked EditText 来编辑文本购物车号码,但我的代码是错误的,我不明白什么问题请帮助我
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:我的代码 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:这些链接上有2个不错的教程:
https://github.com/egslava/edittext-mask https://github.com/egslava/edittext-mask
https://medium.com/@diegoy_kuri/masks-in-android-edit-text-fields-33a2fd47f1af 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).您必须为掩码创建 class,因为属性“app:mask”不能像这样工作(有时像 android:fontFamily)。
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
android.view.InflateException: Binary XML file line #142: Binary XML file line #142: Error inflating class br.com.sapereaude.maskedEditText.MaskedEditText
my xml code:我的 xml 代码:
<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;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.