AutocompleteTextView中的“onClick”会导致错误

时间:2013-08-07 17:52:26

标签: android xml

我有一个autocompletetextview。我想要一个方法来运行“onClick”。这是我的XML:

        <AutoCompleteTextView
            android:id="@+id/GivenByBox"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:onClick="setupMiranda"
            android:gravity="left"
             />

运行此操作时,我会收到错误消息。无论onClick设置为什么,它总是会导致错误。如果我删除android:onclick行一切正常,但这不是我想要的。

以下是logCat的摘录:

08-07 13:56:36.040: E/AndroidRuntime(32735): FATAL EXCEPTION: main
08-07 13:56:36.040: E/AndroidRuntime(32735): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.itsmr.dre_android_clean/com.itsmr.dre_android_clean.MainActivity}: android.view.InflateException: Binary XML file line #46: Error inflating class <unknown>
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.app.ActivityThread.access$700(ActivityThread.java:140)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.os.Handler.dispatchMessage(Handler.java:99)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.os.Looper.loop(Looper.java:137)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.app.ActivityThread.main(ActivityThread.java:4921)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at java.lang.reflect.Method.invokeNative(Native Method)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at java.lang.reflect.Method.invoke(Method.java:511)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at dalvik.system.NativeStart.main(Native Method)
08-07 13:56:36.040: E/AndroidRuntime(32735): Caused by: android.view.InflateException: Binary XML file line #46: Error inflating class <unknown>
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.view.LayoutInflater.createView(LayoutInflater.java:613)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:316)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.app.Activity.setContentView(Activity.java:1924)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at com.itsmr.dre_android_clean.MainActivity.onCreate(MainActivity.java:81)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.app.Activity.performCreate(Activity.java:5188)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
08-07 13:56:36.040: E/AndroidRuntime(32735):    ... 11 more
08-07 13:56:36.040: E/AndroidRuntime(32735): Caused by: java.lang.reflect.InvocationTargetException
08-07 13:56:36.040: E/AndroidRuntime(32735):    at java.lang.reflect.Constructor.constructNative(Native Method)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.view.LayoutInflater.createView(LayoutInflater.java:587)
08-07 13:56:36.040: E/AndroidRuntime(32735):    ... 26 more
08-07 13:56:36.040: E/AndroidRuntime(32735): Caused by: java.lang.NullPointerException
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.widget.AutoCompleteTextView$PassThroughClickListener.access$302(AutoCompleteTextView.java:1226)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.widget.AutoCompleteTextView.setOnClickListener(AutoCompleteTextView.java:200)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.view.View.<init>(View.java:3678)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.widget.TextView.<init>(TextView.java:574)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.widget.EditText.<init>(EditText.java:76)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.widget.AutoCompleteTextView.<init>(AutoCompleteTextView.java:137)
08-07 13:56:36.040: E/AndroidRuntime(32735):    at android.widget.AutoCompleteTextView.<init>(AutoCompleteTextView.java:133)
08-07 13:56:36.040: E/AndroidRuntime(32735):    ... 29 more

无论在Click上设置了什么功能,我都会收到此错误。即使是具有空体的函数也会导致此错误。

导致此错误的原因是什么?

0 个答案:

没有答案