How do we create an extension for Niotron?

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

0 voters

7 Likes

I have made this post as wiki now anyone can edit this post only edit if I do anywhere mistake

1 Like

Nice guide

Thank you for guide

1 Like

@Faraz_Firoz I edited the post, fixed typos and the sample code. :blush:

2 Likes

Thank you @Aquib_Khan and @killer

1 Like

@Faraz_Firoz I really need more guides as i know java but i don’t know extension development properly can you help me

2 Likes

Ofcose I am here for helping people tell which type of guide you want

1 Like

Same thing i was going to ask @Faraz_Firoz i will be waiting for it.

1 Like

Tell me which type of guide you want

1 Like

Nice guide @Faraz_Firoz

Here we want to learn from basic syntax :pray: i. e. What to type and in which format to type

After some time you got my another guide In which I tell you Why java do not work if we copy and paste it 8n Extension developement

My another guide Why java do not work if we copy and paste it in Extension developement?

1 Like

Another guide How do we create an extension that arrange list in ascending/descending order, get min/max from list

How can we save and import the extension in Niotron

You will get the save button in Niotron IDE and for compiling you will get compile extension or something like this I can’t remember it
:sweat_smile:

1 Like

How do we can import kotlin in niotron ide builder anf do further workss? Pls some one give hint about it

I guess, kotlin language is not supported by niotron extension builder.

As far i know only rush allow to write the extension in kotlin language.

2 Likes

Is this code Correct/working? I was testing and trying to learn creating components in any arrangements… but i got this warning