How to create vertical arrangment using an extension?

Hello,
Im using appybuilding code editor to create extension, and i want that my extension should create a vertical scroll arrangement , so how can i add it

Hi @Soham_Shah,
You can see @yusufcihan dynamic arrangements extension source code, it does the same as you want:

And btw, the best place to ask about extensions is the app inventor open source development category:

4 Likes

I get an error when i put this code

import android.content.Context;
import android.util.Log;
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.runtime.*;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.common.ComponentConstants;
import android.view.View;

@DesignerComponent(version = 1,  description = " made by Soham Shah",
        category = ComponentCategory.EXTENSION,
        nonVisible = true,   iconName = "http://yusufcihan.com/img/favicon.png")
@SimpleObject(external = true)
public class DynamicArrangements extends AndroidNonvisibleComponent {
    private ComponentContainer container;
    /**
     * @param container container, component will be placed in
     */
    public DynamicArrangements(ComponentContainer container) {
        super(container.$form());
        this.container = container;
    }
   @SimpleFunction(description = "Creates a dynamic arrangement in selected arrangement.")
    public void CreateArrangement(AndroidViewComponent component) {
      new HVArrangement((ComponentContainer)arrangement);
}
}

Can I know which error​:thinking:

#off-topic
Is there any advantage to using this online editor, besides not having to install ( ant ,gith,VS ) it on our computer?

2 Likes
Buildfile: /projects/goldv2/appinventor-sources/appinventor/build.xml

extensions:

clean:

init:

common_CommonUtils:

init:

CommonUtils:

common_CommonVersion:

init:

CommonVersion:
     [exec] Result: 128
     [exec] Result: 128

CopyToRunLibDir:

components_AndroidRuntime:

init:

CommonConstants:
    [javac] Compiling 6 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/CommonConstants
    [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
    [javac] 1 warning
    [javac] Creating empty /projects/goldv2/appinventor-sources/appinventor/components/build/classes/CommonConstants/com/google/appinventor/components/common/package-info.class
      [jar] Building jar: /projects/goldv2/appinventor-sources/appinventor/build/components/CommonConstants.jar
      [jar] Building jar: /projects/goldv2/appinventor-sources/appinventor/build/components/CommonConstants-gwt.jar

HtmlEntities:
    [mkdir] Created dir: /projects/goldv2/appinventor-sources/appinventor/components/build/classes/HtmlEntities
    [javac] Compiling 1 source file to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/HtmlEntities
    [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
    [javac] 1 warning
      [jar] Building jar: /projects/goldv2/appinventor-sources/appinventor/components/build/HtmlEntities.jar

common_CommonVersion:

init:

CommonVersion:
     [exec] Result: 128
     [exec] Result: 128

AndroidRuntime:
    [mkdir] Created dir: /projects/goldv2/appinventor-sources/appinventor/components/build/classes/AndroidRuntime
    [javac] Compiling 332 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/AndroidRuntime
    [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
    [javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/sohamtshah2005/Mjkl4/Mjkl4.java:16: error: class DynamicArrangements is public, should be declared in a file named DynamicArrangements.java
    [javac] public class DynamicArrangements extends AndroidNonvisibleComponent {
    [javac]        ^
    [javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/sohamtshah2005/Mjkl4/Mjkl4.java:27: error: cannot find symbol
    [javac]       new HVArrangement((ComponentContainer)arrangement);
    [javac]                                             ^
    [javac]   symbol:   variable arrangement
    [javac]   location: class DynamicArrangements
    [javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/sohamtshah2005/Mjkl4/Mjkl4.java:27: error: constructor HVArrangement in class HVArrangement cannot be applied to given types;
    [javac]       new HVArrangement((ComponentContainer)arrangement);
    [javac]       ^
    [javac]   required: ComponentContainer,int,boolean
    [javac]   found: ComponentContainer
    [javac]   reason: actual and formal argument lists differ in length
    [javac] Note: Some input files use or override a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.
    [javac] Note: Some input files use unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.
    [javac] 3 errors
    [javac] 1 warning

BUILD FAILED
/projects/goldv2/appinventor-sources/appinventor/build.xml:35: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/build-common.xml:372: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/components/build.xml:141: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/build-common.xml:118: Compile failed; see the compiler error output for details.

Total time: 8 seconds
oldv2/appinventor-sources/appinventor/build.xml:35: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/build-common.xml:372: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/components/build.xml:141: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/build-common.xml:118: Compile failed; see the compiler error output for details.

Total time: 8 seconds

For me there’s only one. The time when I was restricted to install anything to my pc.

Using online editor cannot rename the project (java) namr, therefore the class name must be the same as the project name.

There is no variable called arrangement, I think you want to type component.

In HVArrangement class, creating a new arrangement need a component container, an integer and a boolean.

@WatermelonIce, can you please edit the code and change whatever is wrong?

Let me check the source code of HVArrangement first and see how it works :wink:

In HVArrangement:


You need to specify container, orientation and scrollable.
Therefore,

import android.content.Context;
import android.util.Log;
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.runtime.*;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.common.ComponentConstants;
import android.view.View;

@DesignerComponent(version = 1,  description = " made by Soham Shah",
        category = ComponentCategory.EXTENSION,
        nonVisible = true,   iconName = "http://yusufcihan.com/img/favicon.png")
@SimpleObject(external = true)
public class DynamicArrangements extends AndroidNonvisibleComponent {
    private ComponentContainer container;
    /**
     * @param container container, component will be placed in
     */
    public DynamicArrangements(ComponentContainer container) {
        super(container.$form());
        this.container = container;
    }
   @SimpleFunction(description = "Creates a dynamic arrangement in selected arrangement.")
    public void CreateArrangement(AndroidViewComponent component) {
      new HVArrangement((ComponentContainer)component, LAYOUT_ORIENTATION_HORIZONTAL /*or LAYOUT_ORIENTATION_VERTICAL*/, true //or false depends on scrollable or not)
}

Note

  1. Constant of orientation:
static final int LAYOUT_ORIENTATION_HORIZONTAL = ComponentConstants.LAYOUT_ORIENTATION_HORIZONTAL; //0

static final int LAYOUT_ORIENTATION_VERTICAL = ComponentConstants.LAYOUT_ORIENTATION_VERTICAL; //1

can you please send the code like you did for below so i can copy and paste

It is from github

You can easily try @yusufcihan source code as i’ve said earlier :

No need to copy all code of the HVArrangement in your extension.Simply import

com.google.appinventor.components.runtime.HVArrangement

Here the output of this constructor ( HVArrangement ) will be better if it was assigned to a variable so you can use later.Something like:

HVArrangement myArrangement = new HVArrangement ( layout,orentationEnum,scrollable );

Well actually I am just showing the code and tell him what should he deals with parameters

1 Like

I thought you told him that becuase he said send me the code, so you sent him the github link :grin: .Any way, he still need to import the HVArrangement class, or at least import its parent packagecom.google.appinventor.components.runtime.*; :man_shrugging:

Just tested, after removing unnecessary imports in my post 11, it works.

1 Like

so what do i need to change?

Did you not see my test code…

1 Like

Also you can see this.It should do it properly :slightly_smiling_face:

1 Like

i copied the same code but i get the error:

Buildfile: /projects/goldv2/appinventor-sources/appinventor/build.xml

extensions:

clean:

init:

common_CommonUtils:

init:

CommonUtils:

common_CommonVersion:

init:

CommonVersion:
     [exec] Result: 128
     [exec] Result: 128

CopyToRunLibDir:

components_AndroidRuntime:

init:

CommonConstants:
    [javac] Compiling 6 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/CommonConstants
    [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
    [javac] 1 warning

HtmlEntities:
    [javac] Compiling 1 source file to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/HtmlEntities
    [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
    [javac] 1 warning

common_CommonVersion:

init:

CommonVersion:
     [exec] Result: 128
     [exec] Result: 128

AndroidRuntime:
    [javac] Compiling 332 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/AndroidRuntime
    [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
    [javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/sohamtshah2005/Mjkl4/Mjkl4.java:25: error: class DynamicArrangements is public, should be declared in a file named DynamicArrangements.java
    [javac] public class DynamicArrangements extends AndroidNonvisibleComponent {
    [javac]        ^
    [javac] Note: Some input files use or override a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.
    [javac] Note: Some input files use unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.
    [javac] 1 error
    [javac] 1 warning

BUILD FAILED
/projects/goldv2/appinventor-sources/appinventor/build.xml:35: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/build-common.xml:372: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/components/build.xml:141: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/build-common.xml:118: Compile failed; see the compiler error output for details.

Total time: 7 seconds
ojects/goldv2/appinventor-sources/appinventor/components/build/HtmlEntities.jar

common_CommonVersion:

init:

CommonVersion:
     [exec] Result: 128
     [exec] Result: 128

AndroidRuntime:
    [mkdir] Created dir: /projects/goldv2/appinventor-sources/appinventor/components/build/classes/AndroidRuntime
    [javac] Compiling 332 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/AndroidRuntime
    [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
    [javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/sohamtshah2005/Mjkl4/Mjkl4.java:25: error: class DynamicArrangements is public, should be declared in a file named DynamicArrangements.java
    [javac] public class DynamicArrangements extends AndroidNonvisibleComponent {
    [javac]        ^
    [javac] Note: Some input files use or override a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.
    [javac] Note: Some input files use unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.
    [javac] 1 error
    [javac] 1 warning

BUILD FAILED
/projects/goldv2/appinventor-sources/appinventor/build.xml:35: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/build-common.xml:372: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/components/build.xml:141: The following error occurred while executing this line:
/projects/goldv2/appinventor-sources/appinventor/build-common.xml:118: Compile failed; see the compiler error output for details.

Total time: 6 seconds