android - Resource not found exception on imageclick -
i trying inflate custom dialog on image click program shows following exception.
on image click following code gets act
iv1.setonclicklistener(new onclicklistener() { public void onclick(view arg0) { final dialog d = new dialog(about.this); d.setcontentview(r.layout.abtdial); d.settitle("about developer"); button dbt = (button) d.findviewbyid(r.id.button1); dbt.setonclicklistener(new onclicklistener() { public void onclick(view v) { d.dismiss(); } }); d.show(); } });
the xml custom dialog is
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/relativelayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <textview android:id="@+id/textview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_alignparenttop="true" android:layout_marginleft="32dp" android:layout_margintop="34dp" android:text="about" android:textappearance="?android:attr/textappearancelarge" android:textcolor="#00bfff" android:textsize="50dp" /> <textview android:id="@+id/textview2" android:layout_width="250dp" android:layout_height="wrap_content" android:layout_alignleft="@+id/textview1" android:layout_below="@+id/textview1" android:layout_margintop="43dp" android:text="some text" android:textappearance="?android:attr/textappearancelarge" android:textcolor="#848484" /> <textview android:id="@+id/textview3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_centerhorizontal="true" android:text="text abc" android:textappearance="?android:attr/textappearancelarge" android:textcolor="#a9e2f3" /> <button android:id="@+id/button1" android:layout_width="match_parent" android:layout_height="40dp" android:layout_above="@+id/textview3" android:layout_centerhorizontal="true" android:layout_marginbottom="17dp" android:background="@style/btn" android:text="dismiss" android:textcolor="#00bfff" android:textsize="35dp" android:typeface="monospace" /> </relativelayout>
the stack trace following code is
08-17 21:18:42.651: e/androidruntime(851): fatal exception: main 08-17 21:18:42.651: e/androidruntime(851): android.view.inflateexception: binary xml file line #61: error inflating class <unknown> 08-17 21:18:42.651: e/androidruntime(851): @ android.view.layoutinflater.createview(layoutinflater.java:518) 08-17 21:18:42.651: e/androidruntime(851): @ com.android.internal.policy.impl.phonelayoutinflater.oncreateview(phonelayoutinflater.java:56) 08-17 21:18:42.651: e/androidruntime(851): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:568) 08-17 21:18:42.651: e/androidruntime(851): @ android.view.layoutinflater.rinflate(layoutinflater.java:623) 08-17 21:18:42.651: e/androidruntime(851): @ android.view.layoutinflater.inflate(layoutinflater.java:408) 08-17 21:18:42.651: e/androidruntime(851): @ android.view.layoutinflater.inflate(layoutinflater.java:320) 08-17 21:18:42.651: e/androidruntime(851): @ android.view.layoutinflater.inflate(layoutinflater.java:276) 08-17 21:18:42.651: e/androidruntime(851): @ com.android.internal.policy.impl.phonewindow.setcontentview(phonewindow.java:207) 08-17 21:18:42.651: e/androidruntime(851): @ android.app.dialog.setcontentview(dialog.java:421) 08-17 21:18:42.651: e/androidruntime(851): @ bitcream.my.notepad.about$1.onclick(about.java:32) 08-17 21:18:42.651: e/androidruntime(851): @ android.view.view.performclick(view.java:2485) 08-17 21:18:42.651: e/androidruntime(851): @ android.view.view$performclick.run(view.java:9080) 08-17 21:18:42.651: e/androidruntime(851): @ android.os.handler.handlecallback(handler.java:587) 08-17 21:18:42.651: e/androidruntime(851): @ android.os.handler.dispatchmessage(handler.java:92) 08-17 21:18:42.651: e/androidruntime(851): @ android.os.looper.loop(looper.java:123) 08-17 21:18:42.651: e/androidruntime(851): @ android.app.activitythread.main(activitythread.java:3683) 08-17 21:18:42.651: e/androidruntime(851): @ java.lang.reflect.method.invokenative(native method) 08-17 21:18:42.651: e/androidruntime(851): @ java.lang.reflect.method.invoke(method.java:507) 08-17 21:18:42.651: e/androidruntime(851): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:839) 08-17 21:18:42.651: e/androidruntime(851): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:597) 08-17 21:18:42.651: e/androidruntime(851): @ dalvik.system.nativestart.main(native method) 08-17 21:18:42.651: e/androidruntime(851): caused by: java.lang.reflect.invocationtargetexception 08-17 21:18:42.651: e/androidruntime(851): @ java.lang.reflect.constructor.constructnative(native method) 08-17 21:18:42.651: e/androidruntime(851): @ java.lang.reflect.constructor.newinstance(constructor.java:415) 08-17 21:18:42.651: e/androidruntime(851): @ android.view.layoutinflater.createview(layoutinflater.java:505) 08-17 21:18:42.651: e/androidruntime(851): ... 20 more 08-17 21:18:42.651: e/androidruntime(851): caused by: android.content.res.resources$notfoundexception: resource not drawable (color or path): typedvalue{t=0x1/d=0x7f060001 a=-1 r=0x7f060001} 08-17 21:18:42.651: e/androidruntime(851): @ android.content.res.resources.loaddrawable(resources.java:1681) 08-17 21:18:42.651: e/androidruntime(851): @ android.content.res.typedarray.getdrawable(typedarray.java:601) 08-17 21:18:42.651: e/androidruntime(851): @ android.view.view.<init>(view.java:1951) 08-17 21:18:42.651: e/androidruntime(851): @ android.widget.textview.<init>(textview.java:344) 08-17 21:18:42.651: e/androidruntime(851): @ android.widget.button.<init>(button.java:108) 08-17 21:18:42.651: e/androidruntime(851): @ android.widget.button.<init>(button.java:104) 08-17 21:18:42.651: e/androidruntime(851): ... 23 more
in button1
xml representation have android:background="@style/btn"
. background
attribute accepts drawables, not styles. that's why have exception message
android.content.res.resources$notfoundexception: resource not drawable
ref: android:background
Comments
Post a Comment