当前位置:操作系统 > 安卓/Android >>

Android本地视频播放器开发--搜索本地视频(2)

1、首先介绍布局代码,主布局代码只含有一个LIstView  --jie_video.xml

[html]
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 
    <ListView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_alignParentBottom="true" 
        android:id="@+id/jievideolistfile" 
    /> 
</RelativeLayout> 

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
 <ListView
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_alignParentBottom="true"
  android:id="@+id/jievideolistfile"
 />
</RelativeLayout>2、下一个布局就是listView的子项的布局

[html]
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" > 
    <ImageView  
        android:layout_width="120dp" 
        android:layout_height="80dp" 
        android:id="@+id/video_img" 
        android:contentDescription="@string/cont" 
        /> 
    <RelativeLayout  
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_toRightOf="@id/video_img" 
        android:layout_alignBottom="@id/video_img" 
        > 
        <TextView  
            android:layout_width="match_parent" 
            android:layout_height="wrap_content" 
            android:id="@+id/video_title" 
            android:gravity="center" 
            android:layout_marginTop="5dp" 
            android:text="@string/title" 
        /> 
         
        <TextView  
            android:layout_width="match_parent" 
            android:layout_height="wrap_content" 
            android:id="@+id/video_time" 
            android:gravity="center" 
            android:layout_alignParentBottom="true" 
            android:layout_marginBottom="5dp" 
            android:text="@string/time" 
        /> 
    </RelativeLayout> 
</RelativeLayout> 

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >
    <ImageView
        android:layout_width="120dp"
        android:layout_height="80dp"
        android:id="@+id/video_img"
        android:contentDescription="@string/cont"
        />
    <RelativeLayout
        android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:layout_toRightOf="@id/video_img"
     android:layout_alignBottom="@id/video_img"
        >
        <TextView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:id="@+id/video_title"
      android:gravity="center"
      android:layout_marginTop="5dp"
      android:text="@string/title"
     />
       
  <TextView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:id="@+id/video_time"
      android:gravity="center"
      android:layout_alignParentBottom="true"
      android:layout_marginBottom="5dp"
      android:text="@string/time"
     />
    </RelativeLayout>
</RelativeLayout>
3、布局都写好了,然后就是Activity的编写,这里涉及到视频的缩略图的显示,所以要用到异步加载功能

JieVideo.java

[java]
package com.zhangjie.graduation.videopalyer; 
 
import java.util.List; 
 
import com.zhangjie.graduation.videopalyer.component.JieVideoListViewAdapter; 
import com.zhangjie.graduation.videopalyer.component.LoadedImage; 
import com.zhangjie.gra

补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,