android - Retrivie VideoID -
i have 2 classes (ytadapter , mainactivity). in ytadapter have method gets user input (keyword) , search youtube videos keyword. done right , working good.
@override public view getview(int position, view convertview, viewgroup parent) { viewholder mholder; if(convertview != null){ mholder = (viewholder)convertview.gettag(); }else{ mholder = new viewholder(); convertview = mlayoutinflater.inflate(r.layout.view_video_item,null); mholder.mvideothumbnail = (imageview)convertview.findviewbyid(r.id.video_thumbnail); mholder.mvideotitle = (textview)convertview.findviewbyid(r.id.video_title); convertview.settag(mholder); } //setting data searchresult result = mvideolist.get(position); mholder.mvideotitle.settext(result.getsnippet().gettitle()); //loading image picasso.with(mactivity).load(result.getsnippet().getthumbnails().getmedium().geturl()).into(mholder.mvideothumbnail); return convertview; }
the problem can see videos not play them. in mainactivity have onitemclicked method should play video, however, can't understand how retrive videoid (string) of 1 of videos in list.
could me done? code of onitemclicked method:
@override public void onitemclick(adapterview<?> parent, view view, int position, long id) { video_id = <<<<------ need videoid of video im clicking on in list of videos. intent videointent = youtubestandaloneplayer.createvideointent(this,appconstants.key,video_id); /*needed: result.getsnippet().get(videoid());*/ startactivity(videointent); }
i thought string variable in ytadpater , use variable in mainactivity, working on now.
you can clicked videoid this:
@override public void onitemclick(adapterview<?> parent, view view, int position, long id) { searchresult searchresult = (searchresult) parent.getitematposition(position); video_id = searchresult.getid().getvideoid(); intent videointent = youtubestandaloneplayer.createvideointent(this,appconstants.key,video_id); /*needed: result.getsnippet().get(videoid());*/ startactivity(videointent); }
Comments
Post a Comment