What to use instead of XML layout in extensions

Hi there's some libraries that require us to add lines to xml layout to take a place in our design like this

    app:fwv_rotateSpeed="6" />

but in app inventor we can't do thatwhich made me think of how to use arrangment instead
so if there's any doc or topic shows how to do that please post it or guid eme how to do it

You cant use FerrisWheellView because library make use kotlin languange not pure java...
(for now).

hi thank you for the information but i used it just as an example of the lines i don't need to use this library

You can try convert to layout

public void InitView(HVArrangement layout){
View v = layout.getView();
FerrisWheellView fwv= (FerrisWheellView) v;

1 Like

im getting this error how to solve it

error: incompatible types: HVArrangement cannot be converted to int
[javac] .setCustomLayout(layout)


/** ~~~~~

  • Created with the AppyBuilder Code Editor.
  • This is a template for basic Extension.
  • Modify this template to customize your extension.
  • **** NOTE: DO NOT use a package name.
  • **** The package name will be created for you automatically.
  • **** Adding a package name will cause a compile error
    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;

//Added imports
import android.app.Activity;
import android.content.Context;
import android.view.ViewGroup;// ViewGroup  |  Android Developers
import android.widget.TextView;// TextView  |  Android Developers
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;

@DesignerComponent(version = 1, description = "This Extension was created with the AppyBuilder Code Editor.
" +
"Create your own here:
category = ComponentCategory.EXTENSION,
nonVisible = true, iconName = "http://appyBuilder.com/extensions/icons/extension.png")
@SimpleObject(external = true)
public class AddTextView extends AndroidNonvisibleComponent {
private ComponentContainer container;
private Context context; //Added
private Activity activity; //Added
* @param container container, component will be placed in
public AddTextView(ComponentContainer container) {
this.container = container;
context = (Context) container.$context(); //Added
activity = (Activity) context; //Added

@SimpleFunction(description="Add A TextView")
public void AddTextView(HVArrangement layout, int id, String text, int width, int height){
ViewGroup myViewGroup = (ViewGroup)layout.getView();
LinearLayout myLinearLayout = (LinearLayout)myViewGroup.getChildAt(0);
TextView myTextView = new TextView(activity);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(width , height);
myLinearLayout.addView(myTextView, id);


Use this Code and adopt, it is from @Ken

PS: for the id add 1

1 Like