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

8 Likes

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

2 Likes

Nice guide

Thank you for guide

1 Like

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

3 Likes

Thank you @Aquib_Khan and @killer

2 Likes

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

3 Likes

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

2 Likes

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

1 Like

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

1 Like

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

1 Like

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

2 Likes

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

1 Like

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:

2 Likes

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

1 Like

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.

3 Likes
1 Like

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