android - spinner cant show data from sd card -
this code add data spinner. first read file name sd card adding spinner. cant work. display first file name.
file yourdir = new file(catagoryfilepath); (file f : yourdir.listfiles()) { if (f.isfile()) { mycatagoryfilename = f.getname(); } try { string categoryfilename[] = mycatagoryfilename.split("@"); for(int = 0; i<categoryfilename.length; i++){ string catagorydata = categoryfilename[i]; if (catagorydata.contains("-")) { string data[] = catagorydata.split("-"); string lang = data[0]; string cat = data[1]; } } string catagoryname = categoryfilename[2]; } catch (exception e) { e.printstacktrace(); } catagory = new arraylist<string>(); catagory.add(myfilename); }
this how set spinner adepter.
catagoryadapter = new arrayadapter<string>(this, r.layout.spinner, catagory); catagoryadapter.setdropdownviewresource(r.layout.spinner); myspinnercatagorylist.setadapter(catagoryadapter);
you not adding name in catagory
list. make these changes loop
running add filenames.
catagory = new arraylist<string>(); file yourdir = new file(catagoryfilepath); (file f : yourdir.listfiles()) { if (f.isfile()) { mycatagoryfilename = f.getname(); catagory.add(myfilename);//mycatagoryfilename } try { string categoryfilename[] = mycatagoryfilename.split("@"); for(int = 0; i<categoryfilename.length; i++){ string catagorydata = categoryfilename[i]; if (catagorydata.contains("-")) { string data[] = catagorydata.split("-"); string lang = data[0]; string cat = data[1]; } } string catagoryname = categoryfilename[2]; } catch (exception e) { e.printstacktrace(); } }
Comments
Post a Comment