I want to use “parseColor()” function, so i include “android.graphics.Color” class;  then i call the function in…

I want to use “parseColor()” function, so i include “android.graphics.Color” class;  then i call the function in this way:

LL.parseColor(“#ffffffff”);

It should work, but appears the alert “Cannot find function parseColor in object …….”

What am i doing wrong?? D:

]]>

12 Commentsto I want to use “parseColor()” function, so i include “android.graphics.Color” class;  then i call the function in…

  1. Anonymous says:

    < ![CDATA[

    LL doesn’t have a parseColor method

    ]]>

  2. Anonymous says:

    < ![CDATA[

    Color.parseColor(“red”) is what you need.


    Also, I think Color is one of the available classes directly in LL, you don’t need to include it.

    ]]>

  3. Anonymous says:

    < ![CDATA[

    So i use the wrong object, I understand.


    Thanks for your help!

    ]]>

  4. Anonymous says:

    < ![CDATA[

    Just noticed, why do you want to use that class?


    0xffffffff is a valid color that you can write that way in JavaScript (it is a zero, an x, and eight characters: alpha, red, green, blue)



    I guess you didn’t know that. Well, now you do 😉

    ]]>

  5. Anonymous says:

    < ![CDATA[

    I already know about the “0x”, I’m just exercising with external functions xD (I didn’t know that the color class was already included) there isn’t a particular reason… The next step is dialogs ^___^

    ]]>

  6. Anonymous says:

    < ![CDATA[

    Oh, I noticed something even I:


    I was trying to create a kind of toggle using the label of the item as boolean state(“0” and “1”, if “0” make something and set label to “1” and vice versa…) but it doesn’t work. Then I’ve noticed that the setLabel method is deprecated xD


    There is another way to make toggles?

    ]]>

  7. Anonymous says:

    < ![CDATA[

    I guess you mean a way to store data into an item, right?


    Use item.setTag(“tag”,data)



    And the setLabel is deprecated in items, but not in shortcuts

    ]]>

  8. Anonymous says:

    < ![CDATA[

    I set the script as shortcut intent on a blank item, I guess it’s not the same thing.


    Anyway, I’ll play a little bit with setTag() to understand how it works

    ]]>

  9. Anonymous says:

    < ![CDATA[

    I think it is.


    Also, I forget to mention, you can use the label to store permanent data, but you need to add a ‘true’parameter at the end shortcut.setLabel(“1”,true)


    http://www.pierrox.net/android/applications/lightning_launcher/script/reference/net/pierrox/lightning_launcher/script/api/Shortcut.html#setLabel(java.lang.String,%20boolean)

    ]]>

  10. Anonymous says:

    < ![CDATA[

    I did it just like that and it works for the first time, but when I press again it should do things and then set again label:



    […]


    var label=Item.get label();



    If(label==”0″){


    […]


    Item.setLabel(“1”,true);


    }



    If(label==”1″){


    […]


    Item.setLabel(“0”,true);


    }



    […]



    But nothing, it stucks on the first “if”


    Now I’m trying to do it with setTag().

    ]]>

  11. Anonymous says:

    < ![CDATA[

    There is an odd behavior with setLabel/getLabel: if not persistent, getLabel will return the old value (the one which is saved, not the displayed one). But if persistent is true, then getLabel should return the value set by setLabel, in theory. The script above should work, maybe there is something else in between.If you display the value of “label”, does it change?

    ]]>

  12. Anonymous says:

    < ![CDATA[

    Well, I realized that in my code there was something conceptually wrong…


    If the label contains 0, enters the first “if”. Then the label content became 1 and enters also the second “if” xD


    So, I correct the code by putting an “else” instead of second if and I replaced the label method with setTag.


    Nothing has changed.


    I also include some toasts to see the various step of the code.


    This is the original code:



    var item=LL.getEvent().getItem();


    var tag=item.getTag()


    var d=item.getParent();



    var edit=d.getProperties().edit();



    var Lcol=Color.parseColor(“#ffffffff”);


    var Dcol=Color.parseColor(“#ff000500”);



    if(tag==””||tag==null){


    item.setTag(0);


    }



    if(tag==0){


    Android.makeNewToast(“zzzzz”,true).show();


    item.setTag(1);


    edit.setInteger(“bgColor”,Lcol);



    }


    else{


    Android.makeNewToast(“hhhhh”,true).show();


    item.setTag(0);


    Android.makeNewToast(tag,true).show();


    edit.setInteger(“bgColor”,Dcol);



    }



    edit.commit();



    EDIT: maybe I’m wrong, but I think there is something wrong with commit().

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *