基于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; //文件类型
?}