string - Android create ArrayList from months name -
string - Android create ArrayList from months name -
i want populate arraylist names of months. month in numeric format database. want convert month number month name , add together array. i've tried it, seems work. every month same name.
int[] months = new int[count]; for(int n=0; n<count; n++) { c.movetonext(); months[n]= c.getint(0); arraylist<string> xvals = new arraylist<string>(); (int = 0; <months.length; i++) { calendar cal=calendar.getinstance(); simpledateformat month_date = new simpledateformat("mmmm"); cal.set(calendar.month,months[i]); string month_name = month_date.format(cal.gettime()); xvals.add(month_name); } }
there's 12 months, can not hard code months array values?
try this:
int[] months = {0,1,2,3,4,5,6,7,8,9,10,11}; arraylist<string> xvals = new arraylist<string>(); (int = 0; < months.length; i++) { calendar cal = calendar.getinstance(); simpledateformat month_date = new simpledateformat("mmmm"); cal.set(calendar.month, months[i]); string month_name = month_date.format(cal.gettime()); xvals.add(month_name); } android string arraylist
Comments
Post a Comment