指定路径获取视频的缩略图

 public class MainActivity extends ListActivity {

    private List<String> items = null;//存放名称
    private List<String> paths = null;//存放路径
    private String rootPath = "/sdcard/LdwRecord";
    private TextView tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tv = (TextView) this.findViewById(R.id.TextView);
        this.getFileDir(rootPath);//获取rootPath目录下的文件.
    }

    public void getFileDir(String filePath) {
        try{
            this.tv.setText("当前路径:"+filePath);// 设置当前所在路径
            items = new ArrayList<String>();
            paths = new ArrayList<String>();
            File f = new File(filePath);
            File[] files = f.listFiles();// 列出所有文件

            // 将所有文件存入list中
            if(files != null){
                int count = files.length;// 文件个数
                for (int i = 0; i < count; i++) {
                    File file = files[i];
                    items.add(file.getName());
                    paths.add(file.getPath());
                }
            }

            ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                    android.R.layout.simple_list_item_1, items);
            this.setListAdapter(adapter);
        }catch(Exception ex){
            ex.printStackTrace();
        }

    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        String path = paths.get(position);
        File file = new File(path);
        //如果是文件夹就继续分解
        if(file.isDirectory()){
            this.getFileDir(path);
        }else{
            new AlertDialog.Builder(this).setTitle("提示").setMessage(file.getName()+" 是一个文件!").setPositiveButton("OK", new DialogInterface.OnClickListener(){

                public void onClick(DialogInterface dialog, int which) {

                }

            }).show();
        }
    }

}  

我现在能取到指定的路径下的视频,显示在listView中,但是我想加个让取到的视频有缩略图,不会加,有哪位大神帮帮我,按我的代码,帮我实现一下。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值