android - How can i write these items for constructor in a for-loop? -


so i'm writing app android, , im still noob in java/android. anyways have 2 strings, 1 names , other emails, , want output them in listview custom adapter. works fine far dont know how set items dynamically (with loop). create adapter , on, used tutorial: http://www.ezzylearning.com/tutorial/customizing-android-listview-items-with-custom-arrayadapter

i changed imageview second textview.

in tutorials code there 5 items added list, need them dynamically, since im not having same amount of name+emails output

i tried putting in for-loop doing:

weather weather_data[] = new weather[names.length]; for(int z=0; z == names.length){     weather[z]={new weather(names[z], emails[z])}; } 

i tried adding "new" infront , trying set null before, trial&error since dont know it.

so can tell me how add items dynamically? (ps: sorry if used wrong names describe anything)

this should work

weather weather_data[] = new weather[names.length];  for(int z=0; z < names.length; z++){     weather_data[z] = new weather(names[z], emails[z]); } 

give read learn how loops work
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/for.html

and 1 arrays
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -