I have 90 labels. I'm trying to change them all with a loop.
Can't figure out what I'm doing wrong
You are not incrementing nmber
Make a list of all your label components, then iterate over the list, using each label's index to set its text value
it does not work like this...
as you can see from the example by @TIMAI2 you need a list of the label components...
see also
How to work with the advanced features
A Multiple Choice Quiz: How to work with the advanced features
Taifun
Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.
No need to keep spamming your topic.
Did you read post 3 which gave you the solution?
You have to make a list of all your label components, then iterate over that list using the any component block.
Any news here?
xyz.kumaraswamy.tools.aix (3.7 KB)
package xyz.kumaraswamy.tools;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.ComponentContainer;
import com.google.appinventor.components.runtime.util.YailList;
import java.lang.reflect.Field;
import java.util.ArrayList;
@SuppressWarnings("unused")
public class Tools extends AndroidNonvisibleComponent {
public Tools(ComponentContainer container) {
super(container.$form());
}
@SimpleFunction(description = "Finds all the components of the Type Given")
public YailList ListAllComponents(String name) throws IllegalAccessException {
ArrayList<Object> components = new ArrayList<>();
Field[] fields = form.getClass().getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true);
Object object = field.get(form);
if (object == null || !object.getClass().getSimpleName().equals(name)) {
continue;
}
components.add(object);
}
return YailList.makeList(components);
}
}
Hope this helps
It doesn't work in companion as of now.
๋๋ 16์ผ ์ ์ mit app inventor๋ฅผ ์๊ฒ ๋์์ต๋๋ค.
๋๋ ํ๋ก๊ทธ๋จ์ ๋ง๋ค์ด ๋ณธ ์ ๋ ์๊ณ ์, ๋๋ ๋ฐฐ์๋ณธ ์ ๋ ์์ต๋๋ค. ํผ์ ๊ณต๋ถํ๋ฉด์ ์ฌ๊ธฐ ์ปค๋ฎค๋ํฐ์ ๋์์ ๋ง์ด ๋ฐ์์ต๋๋ค. ๊ณต๋ถ๋ฅผ ํ๋ค๊ฐ 111696์ ๋๊ฐ์ ์ด๋ ค์์ ๊ฒช์ด ๋ต๋ณ์ ์ฐพ์๋ดค๋๋ฐ ํด๋ต์ ์๋๊ตฐ์.
๊ทธ๋์ ํผ์ app inventor์์ ํด๊ฒฐ์ ์ฐพ์๋ณด๊ธฐ๋ก ํ์ต๋๋ค. ๊ทธ๋ฆฌ๊ณ ํด๊ฒฐ์ ์ฐพ์๋์ต๋๋ค.
์ ๊ฐ ์ฌ๋ฌ๋ถ๊ป ๋ง์ ๋์์ ๋ฐ์ ๊ฒ์ฒ๋ผ ์ ํด๊ฒฐ ๋ฐฉ๋ฒ์ด ์ฌ๋ฌ๋ถ์๊ฒ ๋์์ด ๋๊ธธ ๋ฐ๋๋๋ค.