package com.nandu.Example; //package name of the extension
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.runtime.*;
import com.google.appinventor.components.common.*;
import com.google.appinventor.components.annotations.SimpleFunction;
import java.util.*;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.view.View;//
import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.DesignerProperty;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.annotations.UsesPermissions;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.Component;
import com.google.appinventor.components.runtime.ComponentContainer;
@DesignerComponent(version = 1,
description = ""
category = ComponentCategory.EXTENSION,
nonVisible = true,
iconName = "aiwebres/icon.png") // "aiwebres/icon.png" Change your extension's icon from here; can be a direct url
@SimpleObject(external = true)
public class Example extends AndroidNonvisibleComponent implements Component {
public Context context;
private ComponentContainer container;
public Example(ComponentContainer container) {
super(container.$form());
this.container = container;
context = (Context) container.$context();
}
@SimpleFunction(description=" adding items ")
public void label(HVArrangement paramHVArrangement, String paramString1, int index)
{
ViewGroup layout = (ViewGroup)paramHVArrangement.getView();
TextView tv = new TextView(this.context);
tv.setText(paramString1);
tv.setId(index);
tv.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
(( LinearLayout)linearLayout).addView(tv);
}
}
value is placing them on top of each other: