ich einige Objekte in einem Layout wie Video-Ansicht habe, Textansicht und so weiter, das so kommt:kann nicht auf bar in einer anderen Aktivität, um die Fortschritte
<?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>
Diese eine Gruppe von Reihen in recyclerview ist, und meinen 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();
}
});
}
});
}
});
}
außer progreccess bar und MediaController-. Wenn ich auf diese beiden Elemente zugreifen möchte, erhalte ich einen Null-Zugriffsfehler.
@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);
}
}
Beachten Sie diese Codes. Nach diesen Codes führe ich die Anwendung mit den folgenden Codes aus. Ich habe keinen Zugriff auf Fortschrittsbalken und ich habe den folgenden Fehler.