youtube api - How to solve android.view.InflateException with class <unknown>? -
i using youtubebaseactivity recyclerview adapder.:
android.view.inflateexception: binary xml file line #19: binary xml file line #19: error inflating class <unknown> @ android.view.layoutinflater.inflate(layoutinflater.java:539) @ android.view.layoutinflater.inflate(layoutinflater.java:423)
code
public class youtubevideoplayeractivity extends youtubebaseactivity implements youtubeplayer.oninitializedlistener { private static final int recovery_request = 1; private youtubeplayerview youtubeview; string uri; string title; textview videotitle; recyclerview recyclerview; requestqueue requestqueue; youtubevideoplayersreenadapter adapder; list<videothumblinedata> videothumblinedatas = new arraylist<videothumblinedata>(); @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); intent intent = getintent(); uri = intent.getstringextra("uri"); title = intent.getstringextra("title"); youtubeview = (youtubeplayerview) findviewbyid(r.id.youtube_view); videotitle = (textview)findviewbyid(r.id.videotitle); videotitle.settext(title); youtubeview.initialize(config.youtube_api_key, this); recyclerview =(recyclerview)findviewbyid(r.id.player_list_recycler_view); recyclerview.setlayoutmanager(new linearlayoutmanager(getapplicationcontext())); requestqueue = volley.newrequestqueue(getapplicationcontext()); requestqueue.add(new jsonarrayrequest(json_string[position], new response.listener<jsonarray>() { @override public void onresponse(jsonarray response) { try { (int i=response.length()-1; i>= 0 ;i--){ jsonobject data = (jsonobject) response.get(i); log.d("video :"," :"+response); string ids = data.getstring("id"); string video_headings = data.getstring("video_heading"); string video_ids = data.getstring("video_id"); string video_duration = data.getstring("duration"); videothumblinedatas.add(new videothumblinedata(ids,video_headings,video_ids,video_duration)); } adapder =new youtubevideoplayersreenadapter(videothumblinedatas); recyclerview.setadapter(adapder); adapder.notifydatasetchanged(); }catch (jsonexception e){ e.printstacktrace(); } } }, new response.errorlistener() { @override public void onerrorresponse(volleyerror error) { } })); } } public class youtubevideoplayersreenadapter extends recyclerview.adapter<recyclerview.viewholder> { private context mcontext; private list<videothumblinedata> albumlist; class relatedthumbnailholder extends recyclerview.viewholder { public textview title,duration; public youtubethumbnailview thumbnail; public relatedthumbnailholder(view view) { super(view); title = (textview) view.findviewbyid(r.id.player_title); thumbnail = (youtubethumbnailview) view.findviewbyid(r.id.player_thumbnail); duration = (textview)view.findviewbyid(r.id.player_duration); } } public youtubevideoplayersreenadapter(list<videothumblinedata> albumlist) { this.albumlist = albumlist; } @override public recyclerview.viewholder oncreateviewholder(viewgroup parent, int viewtype) { view view = layoutinflater.from(parent.getcontext()).inflate(r.layout.youtubeplayer_listview, parent,false); return new relatedthumbnailholder(view); } @override public void onbindviewholder(recyclerview.viewholder holder, final int position) { relatedthumbnailholder relatedthumbnailholder = (relatedthumbnailholder)holder; relatedthumbnailholder.title.settext(albumlist.get(position).getvideo_heading()); relatedthumbnailholder.duration.settext(albumlist.get(position).getduration()); relatedthumbnailholder.thumbnail.initialize(config.youtube_api_key, new youtubethumbnailview.oninitializedlistener() { @override public void oninitializationsuccess(youtubethumbnailview youtubethumbnailview, youtubethumbnailloader youtubethumbnailloader) { youtubethumbnailloader.setvideo(albumlist.get(position).getvideo_id()); } @override public void oninitializationfailure(youtubethumbnailview youtubethumbnailview, youtubeinitializationresult youtubeinitializationresult) { } }); relatedthumbnailholder.thumbnail.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { intent = new intent(mcontext, youtubevideoplayeractivity.class); i.putextra("uri",albumlist.get(position).getvideo_id()); i.putextra("title",albumlist.get(position).getvideo_heading()); view.getcontext().startactivity(i); } }); relatedthumbnailholder.title.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { intent = new intent(mcontext, youtubevideoplayeractivity.class); i.putextra("uri",albumlist.get(position).getvideo_id()); i.putextra("title",albumlist.get(position).getvideo_heading()); view.getcontext().startactivity(i); } }); } @override public int getitemcount() { return albumlist.size(); } }
activity_main.xml file using youtubevideoplayeractivity xml file
error comes
inflater android.view.inflateexception class <unknown>
<?xml version="1.0" encoding="utf-8"?> <relativelayout 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" xmlns:app="http://schemas.android.com/apk/res-auto" tools:context=".activity.youtubevideoplayeractivity"> <com.google.android.youtube.player.youtubeplayerview android:id="@+id/youtube_view" android:layout_width="match_parent" android:layout_height="wrap_content"/> <android.support.v7.widget.cardview android:layout_width="match_parent" android:id="@+id/cardview" android:background="#ffffff" android:layout_height="wrap_content" android:layout_below="@+id/youtube_view" android:layout_alignparentright="true" android:layout_alignparentend="true"> <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:text="title" android:gravity="center" android:id="@+id/videotitle" android:layout_alignparentleft="true" android:layout_alignparentstart="true" /> </android.support.v7.widget.cardview> <android.support.v7.widget.recyclerview android:id="@+id/player_list_recycler_view" android:layout_width="match_parent" android:overscrollmode="never" app:layout_behavior="@string/appbar_scrolling_view_behavior" android:layout_height="match_parent" android:layout_below="@+id/cardview" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:layout_margintop="41dp" /> </relativelayout>
Comments
Post a Comment