LabelPlus - Additional methods for the Label component

Hi,

I have tried the extension but I have noticed that both SetClickable and SetSelectable blocks through the following error messages:

java.lang.NoSuchMethodError: android.widget.TextView.hasOnClickListeners
Note: You will not see another error reported for 5 seconds.

java.lang.NoSuchMethodError: android.widget.TextView.isTextSelectable
Note: You will not see another error reported for 5 seconds.

I tried with the demo in this thread and the emulator, not sure why it does not work.

Try with Companion and APK. I should work with both.
Which Android version?

1 Like

Thank for your quick reply, I do not know how but it now works with my android phone, that has the latest version 10, however there is still incompatibility with the emulator. I will try the APK once I finish the app.

I think it might just be an emulator problem. There have been many reports that the emulator does not cope with everything. If you are using the standard ai2 emulator it might be deprecated. There are several topics on our forum that recommend other emulators. I also think the best method for testing live is Companion. I do not use the emulator and I do not test the extensions with the emulator.

Method .isTextSelectable exist from API level 11.

3 Likes

Extension updated. New methods added.

4 Likes

Nice!
Gradient and Shadow have one color label1. Is it possible to have different colors?

nice extension :clap::clap::clap:

1 Like

Thanks. Yes, I know that the SetGradientColorText method changes all the colors of the text. Unfortunately, I haven't found any other method that works differently. Therefore, you have to compromise, if you need a shadow, you can choose not to use a gradient.

1 Like

Another update and new methods.

Wow :+1:

SetCustomFontInRange if not found text, need leave unchanged , now show error: setSpan (-1 ... 2) starts before 0

or it is better to do without searching for text, just change the font for the first letter

I didn't think that someone might want to set a font on text that is not there. But ok, I will protect the extension from unfamiliar text, meanwhile you set the text as it exists :grin:. This is not the end, I have more ideas for the label so another update soon.

I do not understand this:

2 Likes

on Companion error Kodular/

Font not found /storage/emulated/0/AppInventor/assets/font.TTF

in apk, android 7:

Need AdndroidX ?

The extension's path for the companion is set of AppInventor.
This can be solved by checking the platform the user is using in. Else you should try using the full exact path of the typeface file.

Exactly as @Kumaraswamy wrote. I haven't tested it in Kodular, and I don't include codular paths. I will look at it and add it to recognize Kodular.

3 Likes

Could you tell me how to check the platform in the extension? I know path, I know how to detect companion mode, unfortunately I can't find information on how to detect platform.

You can check for classes if they are present for example inbuilt notification component's class name which is there on Kodular and not in Ai2.

14.07.2021_21.44.17_REC 14.07.2021_21.43.08_REC

 public boolean IsAppInventor() {
        try{
            Class.forName("com.google.appinventor.components.runtime.MakeroidNotification");
            return false;
        } catch (ClassNotFoundException e) {
            // do nothing
        }
        return true;
    }
com.google.appinventor.components.runtime.MakeroidNotification is one of the component class package name present in kodular

There maybe other ways which I'm not aware of.

4 Likes

Oh, that is, I check if there is a class that is only in kodular. Clever. Ok, I'm implementing.

5 Likes

New update. New methods for text scroll, and compatibility with absolute and Kodular paths.

4 Likes

awesome :heart_eyes:
if possible please add GotFocus and LostFocus blocks..

1 Like

Why would the label take focus?