Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
190 views
in Technique[技术] by (71.8m points)

Accessing android view in Nativescript

I'm trying to use a loader-plugin for nativescript and run into an error that says:

Error creating Loading Indicator Pop Over: Cannot read property 'drawable' of undefined

It seems that the error comes from using android.view.View in the options for the loader.

There's not much additional information about this error, but from my experience with mobile apps I'd say that this error occurs because the view hasn't loaded, yet.

I tried to apply a timeout, move the call around (from onNavigatingTo to onPageLoad), nothing helped.

Here's the code I'm using:

const options = {
        message: "Daten werden geladen…",
        details: "Bitte warten",
        progress: 0.65,
        margin: 10,
        dimBackground: true,
        color: "#fff", // color of indicator and labels
        // background box around indicator
        // hideBezel will override this if true
        backgroundColor: "black",
        userInteractionEnabled: false, // default true. Set false so that the touches will fall through it.
        hideBezel: true, // default false, can hide the surrounding bezel
        mode: Mode.AnnularDeterminate, // see options below
        android: {
            view: android.view.View, // Target view to show on top of (Defaults to entire window)
            cancelable: true,
            cancelListener: function (dialog) {
                console.log("Loading cancelled");
            }
        },
        ios: {
            view: UIView, // Target view to show on top of (Defaults to entire window)
        }
    };

    loader.show(options);

Nativescript 7.x using Javascript

Any ideas?

question from:https://stackoverflow.com/questions/65922179/accessing-android-view-in-nativescript

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

First of all, I don't like using platform-specific code like android.view.View or UIView without appropriate isIOS/isAndroid wrappers. So I'd advise to use this.page.nativeView or this.page.getViewById('someIdHere').nativeView instead.

Adding zero milliseconds timeout is also a good practice. Just to be sure that page content is available.

Would be great if you could provide me some small example, so I could check on my side


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...