WEB开发网
开发学院手机开发Android 开发 Android 快速实现一个文件选择器 阅读

Android 快速实现一个文件选择器

 2010-02-24 04:48:00 来源:WEB开发网   
核心提示:TextView fm_text_01= (TextView)arg1.findViewById(R.id.fm_text_01);fm_text_01.setText(getItem(arg0).name);//Log.v("vodone",""+arg0+" nam

TextView fm_text_01= (TextView)arg1.findViewById(R.id.fm_text_01);

fm_text_01.setText(getItem(arg0).name);

//Log.v("vodone",""+arg0+" name="+getItem(arg0).name);

/*if (getItem(arg0).equals(".")){

}*/

return arg1 ;

}

}

最后来实现listview

public class frm_openfile extends Activity implements OnClickListener {

ListView lv2;

private File mCurrentDirectory = new File("/sdcard/");

ExpBaseAdapter ap;

String fileEndings[]={"png","bmp","jpg","jpeg","avi","3gp","mp3","mp4"};

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setTitle(R.string.text_selectfile);

setContentView(R.layout.frm_openfile);

lv2 = (ListView)findViewById(R.id.of_lv);

lv2.setCacheColorHint(0x00000000);

ap=new ExpBaseAdapter(this);

lv2.setAdapter(ap);

ListView.OnItemClickListener lv2click = new ListView.OnItemClickListener() {

public void onItemClick(AdapterView parent, View view,

int position, long id) {

// "_id", "ext_number", "name","ann", "intro"

int fid=ap.getItemType((int)id);

String mPath="";

if (fid==1){

String s1=ap.getItem((int)id).name;

if (s1.equals("..")){

mPath=mCurrentDirectory.getParent();

}else{

mPath=mCurrentDirectory.getPath()+"/"+s1+"/";

}

mCurrentDirectory=new File(mPath);

ListFile(mCurrentDirectory);

}else{

Bundle bundle = new Bundle();

bundle.putString("filename",mCurrentDirectory.getPath()+"/"+ ap.getItem((int)id).name);

Intent mIntent = new Intent();

mIntent.putExtras(bundle);

setResult(RESULT_OK, mIntent);

frm_openfile.this.finish();

上一页  1 2 3 4 5  下一页

Tags:Android 快速 实现

编辑录入:coldstar [复制链接] [打 印]
赞助商链接