java - roid.view.InflateException: Binary XML file line #12: Error inflating class RecyclerView -
anyone able me solve why not able run app past inital loading? if click on hourly or daily forecast both crash out. here
07-16 20:06:27.272 2191-2191/com.dredaydesigns.stormy e/androidruntime﹕ fatal exception: main process: com.dredaydesigns.stormy, pid: 2191 java.lang.runtimeexception: unable start activity componentinfo{com.dredaydesigns.stormy/com.dredaydesigns.stormy.ui.hourlyforecastactivity}: android.view.inflateexception: binary xml file line #12: error inflating class recyclerview @ android.app.activitythread.performlaunchactivity(activitythread.java:2184) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2233) @ android.app.activitythread.access$800(activitythread.java:135) @ android.app.activitythread$h.handlemessage(activitythread.java:1196) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:136) @ android.app.activitythread.main(activitythread.java:5001) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:515) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:785) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:601) @ dalvik.system.nativestart.main(native method) caused by: android.view.inflateexception: binary xml file line #12: error inflating class recyclerview @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:707) @ android.view.layoutinflater.rinflate(layoutinflater.java:755) @ android.view.layoutinflater.inflate(layoutinflater.java:492) @ android.view.layoutinflater.inflate(layoutinflater.java:397) @ android.view.layoutinflater.inflate(layoutinflater.java:353) @ android.support.v7.app.appcompatdelegateimplv7.setcontentview(appcompatdelegateimplv7.java:249) @ android.support.v7.app.appcompatactivity.setcontentview(appcompatactivity.java:106) @ com.dredaydesigns.stormy.ui.hourlyforecastactivity.oncreate(hourlyforecastactivity.java:31) @ android.app.activity.performcreate(activity.java:5231) @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1087) @ android.app.activitythread.performlaunchactivity(activitythread.java:2148) at android.app.activitythread.handlelaunchactivity(activitythread.java:2233) at android.app.activitythread.access$800(activitythread.java:135) at android.app.activitythread$h.handlemessage(activitythread.java:1196) at android.os.handler.dispatchmessage(handler.java:102) at android.os.looper.loop(looper.java:136) at android.app.activitythread.main(activitythread.java:5001) at java.lang.reflect.method.invokenative(native method) at java.lang.reflect.method.invoke(method.java:515) at com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:785) at com.android.internal.os.zygoteinit.main(zygoteinit.java:601) at dalvik.system.nativestart.main(native method) caused by: java.lang.classnotfoundexception: didn't find class "android.view.recyclerview" on path: dexpathlist[[zip file "/data/app/com.dredaydesigns.stormy-2.apk"],nativelibrarydirectories=[/data/app-lib/com.dredaydesigns.stormy-2, /system/lib]] @ dalvik.system.basedexclassloader.findclass(basedexclassloader.java:56) @ java.lang.classloader.loadclass(classloader.java:497) @ java.lang.classloader.loadclass(classloader.java:457) @ android.view.layoutinflater.createview(layoutinflater.java:559) @ android.view.layoutinflater.oncreateview(layoutinflater.java:652) @ com.android.internal.policy.impl.phonelayoutinflater.oncreateview(phonelayoutinflater.java:66) @ android.view.layoutinflater.oncreateview(layoutinflater.java:669) @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:694) at android.view.layoutinflater.rinflate(layoutinflater.java:755) at android.view.layoutinflater.inflate(layoutinflater.java:492) at android.view.layoutinflater.inflate(layoutinflater.java:397) at android.view.layoutinflater.inflate(layoutinflater.java:353) at android.support.v7.app.appcompatdelegateimplv7.setcontentview(appcompatdelegateimplv7.java:249) at android.support.v7.app.appcompatactivity.setcontentview(appcompatactivity.java:106) at com.dredaydesigns.stormy.ui.hourlyforecastactivity.oncreate(hourlyforecastactivity.java:31) at android.app.activity.performcreate(activity.java:5231) at android.app.instrumentation.callactivityoncreate(instrumentation.java:1087) at android.app.activitythread.performlaunchactivity(activitythread.java:2148) at android.app.activitythread.handlelaunchactivity(activitythread.java:2233) at android.app.activitythread.access$800(activitythread.java:135) at android.app.activitythread$h.handlemessage(activitythread.java:1196) at android.os.handler.dispatchmessage(handler.java:102) at android.os.looper.loop(looper.java:136) at android.app.activitythread.main(activitythread.java:5001) at java.lang.reflect.method.invokenative(native method) at java.lang.reflect.method.invoke(method.java:515) at com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:785) at com.android.internal.os.zygoteinit.main(zygoteinit.java:601) at dalvik.system.nativestart.main(native method)
here hourlyforecastadapter.
package com.dredaydesigns.stormy.ui; import android.content.intent; import android.os.bundle; import android.os.parcelable; import android.support.v7.app.actionbaractivity; import android.support.v7.widget.linearlayoutmanager; import android.support.v7.widget.recyclerview; import com.dredaydesigns.stormy.r; import com.dredaydesigns.stormy.adapters.houradapter; import com.dredaydesigns.stormy.weather.hour; import java.util.arrays; import butterknife.butterknife; import butterknife.injectview; public class hourlyforecastactivity extends actionbaractivity { private hour[] mhours; @injectview(r.id.recyclerview) recyclerview mrecyclerview; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_hourly_forecast); butterknife.inject(this); intent intent = getintent(); parcelable[] parcelables = intent.getparcelablearrayextra(mainactivity.hourly_forecast); mhours = arrays.copyof(parcelables, parcelables.length, hour[].class); houradapter adapter = new houradapter(this, mhours); mrecyclerview.setadapter(adapter); recyclerview.layoutmanager layoutmanager = new linearlayoutmanager(this); mrecyclerview.setlayoutmanager(layoutmanager); mrecyclerview.sethasfixedsize(true); } }
here houradapter.java.
package com.dredaydesigns.stormy.adapters; import android.content.context; import android.support.v7.widget.recyclerview; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.imageview; import android.widget.textview; import android.widget.toast; import com.dredaydesigns.stormy.r; import com.dredaydesigns.stormy.weather.hour; /** * created andreas on 7/2/2015. */ public class houradapter extends recyclerview.adapter <houradapter.hourviewholder> { private hour [] mhours; private context mcontext; public houradapter(context context,hour [] hours) { mhours = hours; } @override public hourviewholder oncreateviewholder(viewgroup parent, int viewtype) { view view = layoutinflater.from(parent.getcontext()) .inflate(r.layout.hourly_list_item, parent, false); hourviewholder viewholder = new hourviewholder(view); return viewholder; } @override public void onbindviewholder(hourviewholder holder, int position) { holder.bindhour(mhours[position]); } @override public int getitemcount() { return mhours.length; } public class hourviewholder extends recyclerview.viewholder implements view.onclicklistener { public textview mtimelabel; public textview msummarylabel; public textview mtemperaturelabel; public imageview miconimageview; public hourviewholder(view itemview) { super(itemview); mtimelabel = (textview) itemview.findviewbyid(r.id.timelabel); msummarylabel = (textview) itemview.findviewbyid(r.id.summarylabel); mtemperaturelabel = (textview) itemview.findviewbyid(r.id.temperaturelabel); miconimageview = (imageview) itemview.findviewbyid(r.id.iconimageview); } public void bindhour(hour hour) { mtimelabel.settext(hour.gethour()); msummarylabel.settext(hour.getsummary()); mtemperaturelabel.settext(hour.gettemperature() + ""); miconimageview.setimageresource(hour.geticonid()); } @override public void onclick(view v) { string time = mtimelabel.gettext() + ""; string temp = mtemperaturelabel.gettext() +""; string summary = msummarylabel.gettext().tostring(); string message = string.format("at %s %s , %s.", time, temp, summary); toast.maketext(mcontext,message, toast.length_long).show(); } } }
it looks using recycleview tag in layour incorrect. write <recycleview ...
, need write <android.support.v7.widget.recyclerview>
all views using in xml, inflater looking @ android.view package. have exception:
java.lang.classnotfoundexception: didn't find class "android.view.recyclerview"
because recyclerview class located in android.suport.v7.widget package. in cases this, need use full qualified name of view class.
Comments
Post a Comment