使用maskedEditText库时出现以下错误:
我下载了库,然后单击“文件”->“新建”->“其他”->“现有代码中的Android项目”->“添加文件夹”,选中“将项目复制到工作区”
然后我将库文件夹添加到我的项目中:
当我运行时,我有ClassNotFoundException
我的XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:mask="http://schemas.android.com/apk/res/com.example.pppp"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.pppp.MainActivity" >

    <br.com.sapereaude.maskedEditText.MaskedEditText
                        android:id="@+id/phoneNumber"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="3dp"
                        android:background="@null"
                        android:inputType="number"
                        mask:mask="(###) ###-##-##"
                    >
                    </br.com.sapereaude.maskedEditText.MaskedEditText>

</RelativeLayout>

错误
05-30 10:10:38.423: E/AndroidRuntime(32526): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.pppp/com.example.pppp.MainActivity}: android.view.InflateException: Binary XML file line #13: Error inflating class br.com.sapereaude.maskedEditText.MaskedEditText
05-30 10:10:38.423: E/AndroidRuntime(32526):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2077)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at android.app.ActivityThread.access$600(ActivityThread.java:134)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at android.os.Looper.loop(Looper.java:154)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at android.app.ActivityThread.main(ActivityThread.java:4624)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at java.lang.reflect.Method.invokeNative(Native Method)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at java.lang.reflect.Method.invoke(Method.java:511)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at dalvik.system.NativeStart.main(Native Method)
05-30 10:10:38.423: E/AndroidRuntime(32526): Caused by: android.view.InflateException: Binary XML file line #13: Error inflating class br.com.sapereaude.maskedEditText.MaskedEditText
05-30 10:10:38.423: E/AndroidRuntime(32526):    at android.view.LayoutInflater.createView(LayoutInflater.java:608)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:682)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:741)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at android.view.LayoutInflater.inflate(LayoutInflater.java:491)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at com.example.pppp.MainActivity.onCreate(MainActivity.java:13)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at android.app.Activity.performCreate(Activity.java:4479)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1050)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2041)
05-30 10:10:38.423: E/AndroidRuntime(32526):    ... 11 more
05-30 10:10:38.423: E/AndroidRuntime(32526): Caused by: java.lang.reflect.InvocationTargetException
05-30 10:10:38.423: E/AndroidRuntime(32526):    at java.lang.reflect.Constructor.constructNative(Native Method)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
05-30 10:10:38.423: E/AndroidRuntime(32526):    at android.view.LayoutInflater.createView(LayoutInflater.java:588)
05-30 10:10:38.423: E/AndroidRuntime(32526):    ... 22 more
05-30 10:10:38.423: E/AndroidRuntime(32526): Caused by: java.lang.NoClassDefFoundError: br.com.sapereaude.maskedEditText.R$styleable
05-30 10:10:38.423: E/AndroidRuntime(32526):    at br.com.sapereaude.maskedEditText.MaskedEditText.<init>(MaskedEditText.java:43)

最佳答案

尝试将命名空间更改为“maskededitext.maskededitext”。我们可以在“references/maskededitext”中看到名称空间。
例子:

        <MaskedEditText.MaskedEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                mask:mask="+# (###) ##-##"
                android:id="@+id/email" />

08-04 01:21