How do you create such a block for AppInventor?

Hello .
I can with the program "Rush"
create for AppInventor, block number 1, such functionality
2023577
here is the java code with which i can create block #1

  @SimpleFunction(description = " ")
 public static String convertNumber(String var, final String logic)
  {
    return var;
  }

Can anyone show an example Java code, with the help of which,
I'm from my block number one, could in the "rush build",make the appearance of block number 2?

You cannot. The block you created is a function block. You cannot change the color or the appearance of the block to make it look like a math block.

P.S. The program is called Rush, not "rush build".

1 Like

Thank you, now I will know that it's impossible.

Instead, you can create something with similar functionality using helper blocks. There is a block pinned to the block where you can make selections. But you can't do that in Rush right now.

Thank you,
I'm just a programming hobbyist.
I can write programs in "C++" language
I've only been introduced to the Java language for a month.
Where with the help of the Rush program,
I managed to create several blocks of different types
2023588

Here are the blocks I can make
Next, I'm wondering
can i on my own
make some more blocks?
Indeed, in AppInventor there is a wide variety of them,
but I can only make 5 types of blocks,
Further I need an example or a hint.

The block I showed above can be made by compiling the extension in the app inventor sources. Rush does not yet support this feature. You then create a helper class in the helpers directory and then add that class to the input of the function block where you want to have parameter selection.

Class Orientation:

import com.google.appinventor.components.common.OptionList;

import com.google.appinventor.components.common.Default;

import java.util.HashMap;

import java.util.Map;

public enum Orientation implements OptionList<Integer> {

  Horizontal(0),

  Vertical(1);

 

  private int orient;

   Orientation(int orient) {

    this.orient = orient;

  }

  public Integer toUnderlyingValue() {

    return orient;

  }

  private static final Map<Integer, Orientation> lookup = new HashMap<>();

  static {

    for(Orientation orient : Orientation.values()) {

      lookup.put(orient.toUnderlyingValue(), orient);

    }

  }

  public static Orientation fromUnderlyingValue(int orient) {

    return lookup.get(orient);

  }

}

Usage in extension:

@SimpleFunction
public void Orientation(@Options(Orientation.class) int orientation, ListView listView) {
  }

Effect:

orientation

I tried, unfortunately I don't have enough knowledge
so that there is some result :((


"Orientation.class" is not supported in my project.

As mentioned earlier, helpers blocks do not work with the Rush compiler.

2 Likes

I understood you.
And I'm upset that it's not supported. :))

I tried Rush. The way extensions are built is a bit different. I don't see so many pluses in Rush to use it all the time. Building in source is also easy in my opinion. Rush can be useful when using libraries that use Lambd from java8, or libraries written in Kotlin.

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