In this guide I tell how do we create an extension for Niotron.
Where we create extension for Niotron ?
We create extension for Niotron on ide.niotron.com
- To create any extension first we need import
How we import to create a Function blocks(purple block)
import com.google.appinventor.components.annonations.SimpleFunction;
We use this as @SimpleFunction
How we import to create a Property blocks(green block)
import com.google.appinventor.components.annonations.SimpleProperty;
We use this as @SimpleProperty
How we import to create a Event blocks(yellow block)
import com.google.appinventor.components.annonations.SimpleEvent;
We use this as @SimpleEvent
-
We need 1 more import to create Event block
import com.google.appinventor.components.runtime.EventDispatcher;
-
Now If we want to create a button extension we need import of button, for label extension we need import of label
From where we get import
To get import of button search android button on google open second site whose name was developer.android… see from top you got android.widget.Button;
so this is the import of Button
What is import of Button ?
import android.widget.Button;
Code of Button
Button button = new Button(context);
public void
does not return any value but public Object return a value
Data types
void = Does not return anything
Object = Returns a value
String = text
int = number
boolean = True or False
Example code
(Replace the package name with your package name.)
package com.sample;
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.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.SimpleObject;
import
com.google.appinventor.components.annonations.SimpleFunction;
import
com.google.appinventor.components.annonations.SimpleProperty;
import com.google.appinventor.components.runtime.HVArrangement;
import android.widget.Button;
import android.view.View;
import android.widget.FrameLayout;
private Button button;
@SimpleFunction(description = "Creates a button in the given arrangement")
public void Create(HVArrangement arrangement) {
View view = arrangement.getView();
button = new Button(context);
FrameLayout frameLayout = (FrameLayout) view;
frameLayout.addView(button, new FrameLayout.LayoutParams(-1, -1)
}
@SimpleProperty(description = "Sets the text of button")
public void Text(String text) {
button.setText(text);
}
- Helpfull
- Not helpfull