zoukankan      html  css  js  c++  java
  • 读取音乐+图片

    public class MainActivity extends Activity {
    
        private ContentResolver resolver;
        private List<Bean> list=new ArrayList<Bean>();
        private ListView lv;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            resolver = getContentResolver();
            aa();
            lv = (ListView) findViewById(R.id.listview);
            lv.setAdapter(new My());
            
            
        }
        class My extends BaseAdapter{
    
            private ImageView image;
            private TextView tv;
    
            @Override
            public int getCount() {
                // TODO Auto-generated method stub
                return list.size();
            }
    
            @Override
            public Object getItem(int position) {
                // TODO Auto-generated method stub
                return null;
            }
    
            @Override
            public long getItemId(int position) {
                // TODO Auto-generated method stub
                return 0;
            }
    
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                // TODO Auto-generated method stub
                convertView=View.inflate(MainActivity.this, R.layout.item,null);
                image = (ImageView) convertView.findViewById(R.id.imge);
                tv = (TextView) convertView.findViewById(R.id.tv);
                String path=list.get(position).name;
                Bitmap bit=BitmapFactory.decodeFile(path);
                image.setImageBitmap(bit);
                tv.setText(list.get(position).path);
                return convertView;
            }
            
        }
    
        public void aa(){
            Uri uri=MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
            Cursor query = resolver.query(uri,null,null,null,null);
            while(query.moveToNext()){
                  String name=query.getString(query.getColumnIndex(MediaStore.Images.Media.DATA));
                  String path=query.getString(query.getColumnIndex(MediaStore.Images.Media.DISPLAY_NAME));
                  Bean b=new Bean();
                  b.name=name;
                  b.path=path;
                  list.add(b);
            }
        }
    
    }
  • 相关阅读:
    excel VBA构造正则函数(双参数)
    excel VBA构造函数就是这么简单
    excel VBA中正则模块vbscript.regexp的用法
    excel VBA构造正则函数(单参数)
    USB 设备插拔事件处理
    MySQL 修改 root 密码命令
    函数指针
    串口编程需要注意的地方
    写开机自启动程序应该注意的一点
    C++ 中 delete 和 delete[] 的区别
  • 原文地址:https://www.cnblogs.com/leshen/p/7364173.html
Copyright © 2011-2022 走看看