android - can not access to progress bar in an other activity -


i have objects in layout video view,text view , on comes this:

<?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.cardview android:id="@+id/cardview_mypost" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginbottom="@dimen/activity_vertical_margin" app:cardcornerradius="@dimen/activity_vertical_margin" app:cardelevation="@dimen/activity_vertical_margin" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">   <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="wrap_content"    android:background="@color/web_withe_color"    android:animatelayoutchanges="@anim/anim_list"    android:padding="8dp" > <!-- thumbnail image --> <videoview     android:layout_width="200dp"     android:layout_height="200dp"     android:id="@+id/video_orw"     /> <textview     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:textsize="@dimen/worth"     android:id="@+id/txt_titr_videopost"     android:background="#ee8888"     android:layout_alignparenttop="true"     android:layout_alignparentleft="true"     android:layout_alignparentstart="true" /> <textview     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:textappearance="?android:attr/textappearancelarge"     android:text="large text"     android:id="@+id/txt_date_videopost"     android:layout_alignbaseline="@+id/txt_cunter_videopost"     android:layout_alignbottom="@+id/txt_cunter_videopost"     android:layout_alignparentleft="true"     android:layout_alignparentstart="true" /> <textview     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:textappearance="?android:attr/textappearancesmall"     android:text="small text"     android:id="@+id/txt_cunter_videopost"     android:textcolor="@color/bright_foreground_disabled_material_dark"     android:layout_centervertical="true"     android:layout_alignright="@+id/txt_date_videopost"     android:layout_alignend="@+id/txt_date_videopost" /> <mediacontroller     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:id="@+id/mediacontroller2"     android:layout_alignparentbottom="true"     android:layout_alignparentright="true"     android:layout_alignparentend="true"     android:visibility="gone" /> <progressbar     style="?android:attr/progressbarstylelarge"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:id="@+id/progressbar_load_video"     android:layout_centervertical="true"     android:layout_alignright="@+id/txt_titr_videopost"     android:layout_alignend="@+id/txt_titr_videopost" /> </relativelayout> 

this group of row in recyclerview, , code

 public studentviewholder(view v) {         super(v);          progress_video=new progressbar(context);         final progressdialog[] pdialog = new progressdialog[1];         final showmessage sm=new showmessage(context);          thumbnail = (videoview) itemview               .findviewbyid(r.id.video_orw);         titr = (textview) itemview.findviewbyid(r.id.txt_titr_videopost);         year = (textview) itemview.findviewbyid(r.id.txt_date_videopost);         fi = (textview) itemview.findviewbyid(r.id.txt_cunter_videopost);         progressbar=(progressbar) itemview.findviewbyid(r.id.progressbar1);         progress_video=(progressbar) v.findviewbyid(r.id.progressbar_video);          v.setonclicklistener(new onclicklistener() {              @override             public void onclick(view v) {                   sm.show();                   if(videogalery.mediacontrol==null)                 videogalery.mediacontrol=new mediacontroller(context);                   videogalery.mediacontrol.setanchorview(videogalery.videoview);                  videogalery.videoview.setmediacontroller(videogalery.mediacontrol);              int itemposition = dataadapterpostvideo.recyclervvew.getchildlayoutposition(v);                                    videogalery.videoview.setvideouri(uri.parse(dataadapterpostvideo.videolist.get(itemposition).getmedia_path()));                 videogalery.videoview.start();                 videogalery.videoview.seekto(500);                  videogalery.videoview.setonpreparedlistener(new mediaplayer.onpreparedlistener() {                     @override                     public void onprepared(mediaplayer mp) {                        mp.setonbufferingupdatelistener(new mediaplayer.onbufferingupdatelistener() {                            @override                            public void onbufferingupdate(mediaplayer mp, int percent) {                                if(percent==100)                                    sm.hide();                            }                        });                     }                 });             }         });     } 

except progreccess bar , mediacontroller. when want access these 2 elements null access error.

@override public void onbindviewholder(final recyclerview.viewholder holder, int position) {     if (holder instanceof studentviewholder ) {          galery video= videolist.get(position);           if(string.valueof(video.getmime_type()).contains("video")) {             ((studentviewholder) holder).titr.settext(string.valueof(video.gettitel()));             ((studentviewholder) holder).year.settext(string.valueof(video.getpublish_at()));             ((studentviewholder) holder).fi.settext(string.valueof(video.getid()));             ((studentviewholder) holder).thumbnail.setvideouri(uri.parse(video.getmedia_path()));             ((studentviewholder) holder).progress_video.setvisibility(view.visible);             ((studentviewholder) holder).thumbnail.setonpreparedlistener(new mediaplayer.onpreparedlistener() {                 @override                 public void onprepared(mediaplayer mp) {                     mp.setonbufferingupdatelistener(new mediaplayer.onbufferingupdatelistener() {                         @override                         public void onbufferingupdate(mediaplayer mp, int percent) {                             if(percent==100)                                 ((studentviewholder) holder).progress_video.setvisibility(view.gone);                         }                     });                 }             });             ((studentviewholder) holder).thumbnail.seekto(2000);             // log.i("hamed",string.valueof(video.getid()));         }        animate((studentviewholder) holder);      } else {         ((progressviewholder) holder).progressbar.setindeterminate(true);     } } 

pay attention these codes. after these codes run application below codes. don't have access progressbar , face below error.

while can solved closer @ code. answer little differently.

npes views come due reasons such as:

  • the view trying find not present in layout.
  • the view trying find has different id trying find.
  • the view doesn't have id.

Comments

  1. As claimed by Stanford Medical, It's in fact the SINGLE reason women in this country get to live 10 years more and weigh 19 KG lighter than us.

    (Just so you know, it has NOTHING to do with genetics or some secret diet and really, EVERYTHING about "how" they eat.)

    P.S, I said "HOW", not "what"...

    Tap on this link to reveal if this little quiz can help you unlock your true weight loss potential

    ReplyDelete

Post a Comment

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -