Selom
Selom

Reputation: 402

NativeScript FloatingActionButton from github.com/Clans/FloatingActionButton

I'm very new to NativeScript. I chose it compared to React Native because I wanted 100% access to native API. I started playing with native plugins and read some tutorials like this one native libraries Now I'm trying to follow the same principle with this plugin FloatingActionButton

var app = require("application");
var platformModule = require("platform");
var fs = require("file-system");
var imageSource = require("image-source");

function creatingFab(args) {

    var fabMenu = new com.github.clans.fab.FloatingActionMenu(app.android.foregroundActivity);
    var fabButton = new com.github.clans.fab.FloatingActionButton(args.object.android);
    fabButton.setButtonSize(FloatingActionButton.SIZE_MINI);
    fabButton.setLabelText("Hello Button");
       
    //fabButton.setImageResource(imageSource.fromResource("logo"));
  
    fabMenu.addMenuButton(fabButton);
    fabMenu.hideMenuButton(false);
    
}

<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="onNavigatingTo" class="page">
  
    <Page.actionBar>
        <ActionBar title="My App" icon="" class="action-bar">
        </ActionBar>
    </Page.actionBar>
   
    <StackLayout class="p-20">
        <Label text="Tap the button" class="h1 text-center"/>
        <Button text="TAP" tap="{{ onTap }}" class="btn btn-primary btn-active"/>
        <Label text="{{ message }}" class="h2 text-center" textWrap="true"/>
    </StackLayout>
    <android>
        <placeholder id="fab" tap="fabClick" class="fab-button" margin="15" creatingView="creatingFab"/>
   </android>
</Page>

error in emulator

Thank you in advance for your help

Upvotes: 0

Views: 242

Answers (1)

Marek Maszay
Marek Maszay

Reputation: 1557

try is as this based on this http://docs.nativescript.org/api-reference/classes/application.androidapplication.html#foregroundactivity

var fabMenu = new com.github.clans.fab.FloatingActionMenu(app.AndroidApplication.foregroundActivity);

Upvotes: 1

Related Questions