Writing extension: how do you declare list parameter?

Hi All!
I'm writing extension (instance used is called TEST1) replacing my procedure made of blocks.
I need a method that manipulates list (light blue block) of numbers (dark blue blocks).
For simplicity let's call it ZListy ( List lista, int nr) - method ZListy manipulates list list using some parameter nr.
It will be called like this:

My problem is using proper type for List

Regards, Kuba
p.s. link to docs to read would be appreciated too

The input variable "lista" must be declared as YailList.

1 Like

Thanks a lot.
BTW what environment do you use to develop extensions and how do you import appinventor specific classes (I had some problems adding new repo to Android studio- we'll have to try agn).
b rgds

I use VisualCode to write code. As for the compilation, now I use Rush, when I compiled in AppInventor sources. You need to clone the github repository. The java files must be placed in the correct folder.



Dear @Patryk_F ,
How to add appinventor repos to my java project
Maybe you could share with me sample project ?
I'm new to java and:
a) I can build my 1st app in InteliJ without YailDictionary, YailList and other AppInventor sources
b) I can make simple extention using Rush or Niotron (made a few) - but I have no way to debug them if they contain imports from appinventor (as they are not in public repo's)
So the problem is how to add appinventor repos to my java project...
regards, Kuba

1 Like

there are these instructions for Eclipse... for Android Studio it is similar

1 Like

Rush has a built-in repository. Any imports from AppInventor should work there without any extra work.

import com.google.appinventor.components.runtime.util.YailList;

Yes. But as I tried to explain I also need it in debugger - either intellij (preferably) or vsc.
This is the "only" problem.

So far:

  1. YailDictionary is quite simple similar to standard java HashMap.
    So until I find proper solution, I will write and debug HashMap and tweak to fancy YailDictionary...
  2. Sample for rookies like me (hopefully without errors):
package com.sample.t2;

import android.app.Activity;
import android.content.Context;
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.ComponentContainer;
import com.google.appinventor.components.runtime.EventDispatcher;

import com.google.appinventor.components.runtime.util.YailDictionary;

        version = 1,
        description = "test 2 extension",
        category = ComponentCategory.EXTENSION,
        nonVisible = true,
        iconName = "")

@SimpleObject(external = true)
@UsesLibraries(libraries = "")
@UsesPermissions(permissionNames = "")

public class T2 extends AndroidNonvisibleComponent {

    //Activity and Context
    private Context context;
    private Activity activity;
    private YailDictionary ostatnia = new YailDictionary();
    private int someValue = 0;

    public T2(ComponentContainer container){
        this.activity = container.$context();
        this.context = container.$context();

        someValue = 2;

    @SimpleFunction(description = "Returns Route")
    public YailDictionary Testowa (String zMiejsca, String doMiejsca, double odleglosc) {
        YailDictionary  wyn = new YailDictionary();
        YailDictionary  wyn2 = new YailDictionary();
        wyn.put("route",wyn2 );
        ostatnia = new YailDictionary (wyn);
        return wyn;

    @SimpleProperty(category = PropertyCategory.BEHAVIOR, description="Previous route")
    public YailDictionary Ostatnia () {
        return ostatnia;
    public void Ostatnia(YailDictionary ostatnia) {
        this.ostatnia = ostatnia;

    @SimpleFunction(description = "Sample Function Generated by Niotron")
    public int TestFunction(int a, int b, String c){
        return a+b;
    @SimpleEvent(description = "Event no parameters")
    public void TestEvent(){
        EventDispatcher.dispatchEvent(this, "TestEvent");
    @SimpleEvent(description = "Event returns result from TestFunction")
    public void TestEvent2(int c){
        EventDispatcher.dispatchEvent(this, "TestEvent2",c);

    @SimpleEvent(description = "Event returns string c from TestFunction")
    public void TestEvent3(String c){
        EventDispatcher.dispatchEvent(this, "TestEvent3",c);

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.