首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

基于SD卡得资料选择器

2012-06-26 
基于SD卡得文件选择器由于模块结构很简单,所以把遍历文件的方法放在Activity上了?public class AdapterFil

基于SD卡得文件选择器



由于模块结构很简单,所以把遍历文件的方法放在Activity上了

?public class AdapterFilePicker extends BaseAdapter {   ?        private Context mContext;   ?        private Vector mItems = new Vector();   ?        private LinearLayout layout, layout_more;   ?        private LayoutInflater inflate;   ?        private TextView textViewItem;   ?  ?        public AdapterFilePicker(Context context) {   ?                mContext = context;   ?                inflate = (LayoutInflater) mContext   ?                                .getSystemService(android.content.Context.LAYOUT_INFLATER_SERVICE);   ?        }   ?  ?        public void addItem(FileData item) {   ?                mItems.add(item);   ?        }   ?  ?        public FileData getItem(int it) {   ?                return (FileData) mItems.elementAt(it);   ?        }   ?  ?        public int getCount() {   ?                return mItems.size();   ?        }   ?  ?        public long getItemId(int arg0) {   ?                return arg0;   ?        }   ?  ?        public int getItemType(int arg0) {   ?                return getItem(arg0).type;   ?        }   ?  ?        public void clearItems() {   ?                mItems.clear();   ?        }   ?  ?        public View getView(int position, View view, ViewGroup arg2) {   ?                if(null == view){   ?                        view = (LinearLayout) inflate.inflate(R.layout.item_filepicker_listview, null);   ?                }   ?                textViewItem = (TextView) view.findViewById(R.id.textViewFileName);   ?                textViewItem.setText(getItem(position).name);   ?                return view;   ?        }   ?  ?}  


?/** 
? * 文件结构 
? * @author Administrator 
? * 
? */ 
?public class FileData {  
?                public String name; //文件名  
?                public int type; //文件类型  
?} 

热点排行