android holo everywhere - HoloEverywhere AutoCompleteTextView java.lang.ClassCastException -
i trying holoeverywhere class autocompletetextview work app. main reason want holo theme work on pre 3.0 devices (specifically api levels 8-10) here main activity code:
package com.example.testautocomp; import org.holoeverywhere.widget.autocompletetextview; import android.app.activity; import android.os.bundle; import android.widget.arrayadapter; public class mainactivity extends activity { private autocompletetextview m_edit; private static final string[] items = { "lorem", "ipsum", "dolor", "sit", "amet", "consectetuer", "adipiscing", "elit", "morbi", "vel", "augue", "purus", "sitter", "sitting", "sither", "sithar" }; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); m_edit = (autocompletetextview)findviewbyid(r.id.edit2); m_edit.setadapter(new arrayadapter<string>(this, android.r.layout.simple_dropdown_item_1line, items)); } }
also activity_main.xml code:
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <autocompletetextview android:id="@+id/edit2" android:layout_width="match_parent" android:layout_height="wrap_content" android:completionthreshold="1" android:hint="testing" /> </linearlayout>
when run app, goes debugger eclipse , after pressing resume (or f8) continue thread, app crashes/force closes , following error in logcat:
04-19 17:52:56.342: w/dalvikvm(675): threadid=1: thread exiting uncaught exception (group=0x409c01f8) 04-19 17:52:56.422: e/androidruntime(675): fatal exception: main 04-19 17:52:56.422: e/androidruntime(675): java.lang.runtimeexception: unable start activity componentinfo{com.example.testautocomp/com.example.testautocomp.mainactivity}: java.lang.classcastexception: android.widget.autocompletetextview cannot cast org.holoeverywhere.widget.autocompletetextview 04-19 17:52:56.422: e/androidruntime(675): @ android.app.activitythread.performlaunchactivity(activitythread.java:1956) 04-19 17:52:56.422: e/androidruntime(675): @ android.app.activitythread.handlelaunchactivity(activitythread.java:1981) 04-19 17:52:56.422: e/androidruntime(675): @ android.app.activitythread.access$600(activitythread.java:123) 04-19 17:52:56.422: e/androidruntime(675): @ android.app.activitythread$h.handlemessage(activitythread.java:1147) 04-19 17:52:56.422: e/androidruntime(675): @ android.os.handler.dispatchmessage(handler.java:99) 04-19 17:52:56.422: e/androidruntime(675): @ android.os.looper.loop(looper.java:137) 04-19 17:52:56.422: e/androidruntime(675): @ android.app.activitythread.main(activitythread.java:4424) 04-19 17:52:56.422: e/androidruntime(675): @ java.lang.reflect.method.invokenative(native method) 04-19 17:52:56.422: e/androidruntime(675): @ java.lang.reflect.method.invoke(method.java:511) 04-19 17:52:56.422: e/androidruntime(675): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:784) 04-19 17:52:56.422: e/androidruntime(675): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:551) 04-19 17:52:56.422: e/androidruntime(675): @ dalvik.system.nativestart.main(native method) 04-19 17:52:56.422: e/androidruntime(675): caused by: java.lang.classcastexception: android.widget.autocompletetextview cannot cast org.holoeverywhere.widget.autocompletetextview 04-19 17:52:56.422: e/androidruntime(675): @ com.example.testautocomp.mainactivity.oncreate(mainactivity.java:22) 04-19 17:52:56.422: e/androidruntime(675): @ android.app.activity.performcreate(activity.java:4465) 04-19 17:52:56.422: e/androidruntime(675): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1049) 04-19 17:52:56.422: e/androidruntime(675): @ android.app.activitythread.performlaunchactivity(activitythread.java:1920) 04-19 17:52:56.422: e/androidruntime(675): ... 11 more
how fix castclassexception?
no, action above incorrect. should change activity base class on org.holoeverywhere.app.activity.
Comments
Post a Comment