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에서 해결을 찾아보기로 했습니다. 그리고 해결을 찾아냈습니다.
제가 여러분께 많은 도움을 받은 것처럼 제 해결 방법이 여러분에게 도움이 되길 바랍니다.