• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

检索火力视频中的Android

java 来源:Reinhard Bonnke 4次浏览

嗨,大家好我已经succefully通过活动上传的视频到火力点,现在我想查看它们进入recyclerview但我不是得到它的权利检索火力视频中的Android

blog_row.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="3dp"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

     <VideoView 
      android:id="@+id/post_video" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:clickable="true" /> 

     <TextView 
      android:id="@+id/post_title" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:paddingBottom="1dp" 
      android:paddingLeft="5dp" 
      android:text="Post Title Goes Here" 
      android:textColor="@android:color/black" 
      android:textSize="14sp" 
      android:textStyle="bold" /> 

     <TextView 
      android:id="@+id/post_desc" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:paddingBottom="5dp" 
      android:paddingLeft="5dp" 
      android:text="The Post description goes here" 
      android:textColor="@android:color/holo_red_light" 
      android:textSize="13sp" 
      android:textStyle="bold" /> 

    </LinearLayout> 

</android.support.v7.widget.CardView> 

LatestVideos.java

public class Latest extends Fragment{ 

    private RecyclerView mBlogList; 
    private GridLayoutManager gridLayoutManager; 
    private DatabaseReference mDatabase; 


    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
          Bundle savedInstanceState) { 
     // Inflate the layout for this fragment 
     View view = inflater.inflate(R.layout.tab1, container, false); 

     mDatabase = FirebaseDatabase.getInstance().getReference().child("videos"); 

     mDatabase.keepSynced(true); 

     mBlogList = (RecyclerView) view.findViewById(R.id.blog_list); 
     mBlogList.setHasFixedSize(true); 
     mBlogList.setLayoutManager(new LinearLayoutManager(getContext())); 


     FloatingActionButton fab = (FloatingActionButton) view.findViewById(R.id.fab); 
     fab.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View view) { 

       Intent intent = new Intent(getActivity(), UploadActivity.class); 
       startActivity(intent); 
      } 
     }); 


     return view; 
    } 

    @Override 
    public void onStart() { 
     super.onStart(); 


     FirebaseRecyclerAdapter<Blog, BlogViewHolder> firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<Blog, Latest.BlogViewHolder>(
       Blog.class, 
       R.layout.blog_row, 
       Latest.BlogViewHolder.class, 
       mDatabase 

     ) { 
      @Override 
      protected void populateViewHolder(Latest.BlogViewHolder viewHolder, Blog model, int position) { 

       viewHolder.setTitle(model.getTitle()); 
       viewHolder.setDesc(model.getDesc()); 
       viewHolder.setImage(getActivity().getApplicationContext(),model.getImage()); 

      } 
     }; 

     mBlogList.setAdapter(firebaseRecyclerAdapter); 


    } 

    public static class BlogViewHolder extends RecyclerView.ViewHolder{ 

     View mView; 


     public BlogViewHolder(View itemView) { 
      super(itemView); 

      mView = itemView; 
     } 
     public void setTitle(String title){ 
      TextView post_title = (TextView) mView.findViewById(R.id.post_title); 
      post_title.setText(title); 
     } 

     public void setDesc(String desc){ 
      TextView post_desc = (TextView) mView.findViewById(R.id.post_desc); 
      post_desc.setText(desc); 
     } 

     public void setImage(Context ctx, String video){ 
      VideoView post_video = (VideoView) mView.findViewById(R.id.post_video); 
      load(video).into(post_video); 
     } 
    } 

    public void onResume(){ 
     super.onResume(); 

     // Set title bar 
     ((MainContent) getActivity()) 
       .setActionBarTitle("Lol Videos"); 

    } 

} 

Blog.java

public class Blog { 

    private String title; 
    private String desc; 
    private String video; 

    public Blog(){ 

    } 

    public Blog(String title, String desc, String video) { 
     this.title = title; 
     this.desc = desc; 
     this.video = video; 
    } 

    public String getTitle() { 
     return title; 
    } 

    public void setTitle(String title) { 
     this.title = title; 
    } 

    public String getDesc() { 
     return desc; 
    } 

    public void setDesc(String desc) { 
     this.desc = desc; 
    } 

    public String getVideo() { 
     return video; 
    } 

    public void setVideo(String video) { 
     this.video = video; 
    } 
} 

帮我们弄清楚这一点。我一整天都在尝试,但它不起作用。但如果我更换图像的视频,我的作品完美


===========解决方案如下:

这是即时得到它错了..

public void setImage(Context ctx, String video){ 
      VideoView post_video = (VideoView) mView.findViewById(R.id.post_video); 
      load(video).into(post_video); 
     } 

林不知道如何实现视频URI这里


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)