android - selectableItemBackground crashing App -
i'm trying make imagebutton using android:background="?attr/selectableitembackground"
app crashed. following answer , question. idea?
thanks help.
activity.xml
<imagebutton android:id="@+id/signup" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignleft="@+id/signin" android:layout_alignparentbottom="true" android:layout_marginbottom="80dp" android:background="?attr/selectableitembackground" android:src="@drawable/sign_up" android:contentdescription="@string/button_sign_up" />
log cat
05-31 18:50:24.077: w/dalvikvm(28619): threadid=1: thread exiting uncaught exception (group=0x41d0b2a0) 05-31 18:50:24.082: e/androidruntime(28619): fatal exception: main 05-31 18:50:24.082: e/androidruntime(28619): java.lang.runtimeexception: unable start activity componentinfo{yai.properti.tujuh.tujuh.tujuh/yai.properti.tujuh.tujuh.tujuh.welcomeactivity}: android.view.inflateexception: binary xml file line #9: error inflating class android.widget.imagebutton 05-31 18:50:24.082: e/androidruntime(28619): @ android.app.activitythread.performlaunchactivity(activitythread.java:2110) 05-31 18:50:24.082: e/androidruntime(28619): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2135) 05-31 18:50:24.082: e/androidruntime(28619): @ android.app.activitythread.access$700(activitythread.java:140) 05-31 18:50:24.082: e/androidruntime(28619): @ android.app.activitythread$h.handlemessage(activitythread.java:1237) 05-31 18:50:24.082: e/androidruntime(28619): @ android.os.handler.dispatchmessage(handler.java:99) 05-31 18:50:24.082: e/androidruntime(28619): @ android.os.looper.loop(looper.java:137) 05-31 18:50:24.082: e/androidruntime(28619): @ android.app.activitythread.main(activitythread.java:4921) 05-31 18:50:24.082: e/androidruntime(28619): @ java.lang.reflect.method.invokenative(native method) 05-31 18:50:24.082: e/androidruntime(28619): @ java.lang.reflect.method.invoke(method.java:511) 05-31 18:50:24.082: e/androidruntime(28619): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1038) 05-31 18:50:24.082: e/androidruntime(28619): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:805) 05-31 18:50:24.082: e/androidruntime(28619): @ dalvik.system.nativestart.main(native method) 05-31 18:50:24.082: e/androidruntime(28619): caused by: android.view.inflateexception: binary xml file line #9: error inflating class android.widget.imagebutton 05-31 18:50:24.082: e/androidruntime(28619): @ android.view.layoutinflater.createview(layoutinflater.java:613) 05-31 18:50:24.082: e/androidruntime(28619): @ com.android.internal.policy.impl.phonelayoutinflater.oncreateview(phonelayoutinflater.java:56) 05-31 18:50:24.082: e/androidruntime(28619): @ android.view.layoutinflater.oncreateview(layoutinflater.java:660) 05-31 18:50:24.082: e/androidruntime(28619): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:685) 05-31 18:50:24.082: e/androidruntime(28619): @ android.view.layoutinflater.rinflate(layoutinflater.java:746) 05-31 18:50:24.082: e/androidruntime(28619): @ android.view.layoutinflater.inflate(layoutinflater.java:489) 05-31 18:50:24.082: e/androidruntime(28619): @ android.view.layoutinflater.inflate(layoutinflater.java:396) 05-31 18:50:24.082: e/androidruntime(28619): @ android.view.layoutinflater.inflate(layoutinflater.java:352) 05-31 18:50:24.082: e/androidruntime(28619): @ com.android.internal.policy.impl.phonewindow.setcontentview(phonewindow.java:316) 05-31 18:50:24.082: e/androidruntime(28619): @ android.app.activity.setcontentview(activity.java:1924) 05-31 18:50:24.082: e/androidruntime(28619): @ yai.properti.tujuh.tujuh.tujuh.welcomeactivity.oncreate(welcomeactivity.java:19) 05-31 18:50:24.082: e/androidruntime(28619): @ android.app.activity.performcreate(activity.java:5188) 05-31 18:50:24.082: e/androidruntime(28619): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1094) 05-31 18:50:24.082: e/androidruntime(28619): @ android.app.activitythread.performlaunchactivity(activitythread.java:2074) 05-31 18:50:24.082: e/androidruntime(28619): ... 11 more 05-31 18:50:24.082: e/androidruntime(28619): caused by: java.lang.reflect.invocationtargetexception 05-31 18:50:24.082: e/androidruntime(28619): @ java.lang.reflect.constructor.constructnative(native method) 05-31 18:50:24.082: e/androidruntime(28619): @ java.lang.reflect.constructor.newinstance(constructor.java:417) 05-31 18:50:24.082: e/androidruntime(28619): @ android.view.layoutinflater.createview(layoutinflater.java:587) 05-31 18:50:24.082: e/androidruntime(28619): ... 24 more 05-31 18:50:24.082: e/androidruntime(28619): caused by: android.content.res.resources$notfoundexception: resource not drawable (color or path): typedvalue{t=0x2/d=0x7f010015 a=-1} 05-31 18:50:24.082: e/androidruntime(28619): @ android.content.res.resources.loaddrawable(resources.java:1925) 05-31 18:50:24.082: e/androidruntime(28619): @ android.content.res.typedarray.getdrawable(typedarray.java:601) 05-31 18:50:24.082: e/androidruntime(28619): @ android.view.view.<init>(view.java:3449) 05-31 18:50:24.082: e/androidruntime(28619): @ android.widget.imageview.<init>(imageview.java:114) 05-31 18:50:24.082: e/androidruntime(28619): @ android.widget.imagebutton.<init>(imagebutton.java:87) 05-31 18:50:24.082: e/androidruntime(28619): @ android.widget.imagebutton.<init>(imagebutton.java:83) 05-31 18:50:24.082: e/androidruntime(28619): ... 27 more
@gopal gopi correct. if have appcompat v7 imported project, use android:background in xml:
android:background="?android:attr/selectableitembackground"
also, make sure whatever item use on has android:clickable="true"
good luck!
Comments
Post a Comment