1. Download our Official Android App: Forums for Android!

How to generate 5 Image objects or Buttons using code (maybe Java) in Tasker?

Discussion in 'Android Apps & Games' started by darkpixie, Oct 8, 2017.

  1. darkpixie

    darkpixie Lurker
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    7
    Joined:
    Oct 8, 2017

    Oct 8, 2017
    7
    0
    15
    When creating for example image by code, there is some code snippet inside. I wanted to replace the x position in there with variable PosX, which I would like to set beforehand. Unfortunately the code does not recognize nested variables.

    What I wanted to achieve is some kind of a line made from images in form of rectangles automatically after I click the button or start a task.

    I would like to set the distance between rectangles as well as their size, but Tasker is so mysterious with the nested Java code for image and variable PosX and PosY don't work inside.

    Any ideas?
     

    Advertisement

  2. Thom

    Thom  
    VIP Member
    Rank:
     #21
    Points:
    1,318
    Posts:
    12,016
    Joined:
    Feb 16, 2011

    Feb 16, 2011
    12,016
    4,978
    1,318
    Male
    Software Developer
    Keene, NH USA
    Have you tried creating a Scene using the built-in tools? Any scene? Master that first.

    ... Thom
     
    #2 Thom, Oct 8, 2017
    Last edited: Nov 25, 2017
  3. darkpixie

    darkpixie Lurker
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    7
    Joined:
    Oct 8, 2017

    Oct 8, 2017
    7
    0
    15
    Dear Thom,

    I think I mastered manually alot of things, but as You know, when creating manually some Button gives code in form of Java I think in the Content, in which I replaced x position with PosX variable, but unfortunately for me, even Variable Set for PosX to 100 before the creation of a button, even with time interval of 1 second, is not recognized.

    Can object content include variables predefined? How?

    Should I take all content before and after into " like this:

    "contentbefore"+%PosX+"contentafter"

    or maybe there is no way at all?

    thanks again
     
  4. darkpixie

    darkpixie Lurker
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    7
    Joined:
    Oct 8, 2017

    Oct 8, 2017
    7
    0
    15
    When I click the button, Element -> Create makes 2 buttons. Every field in each or those 2 button has this standard code with which I would like to interact, but I dont know how to pass variables to it:


    <ImageElement sr=""ve="2"><RectElement sr="background"><Str sr="arg0"ve="3"/><Int sr="arg1"val="0"/><Str sr="arg2"ve="3">#FFFFDB00</Str><Str sr="arg3"ve="3"/><Int sr="arg4"val="0"/><Str sr="arg5"ve="3">#FF000000</Str><Int sr="arg6"val="0"/><Int sr="arg7"val="0"/><geom>-1,-1,-1,-1,-1,-1,-1,-1</geom><flags>4</flags></RectElement>
    <Str sr="arg0"ve="3">tetris02</Str><Img sr="arg1"ve="2"/>
    <Int sr="arg2"val="255"/><Str sr="arg3"ve="3"/>
    <geom>-1,-1,-1,-1,300,100,150,60</geom><flags>4</flags></ImageElement>

    I want just to replace the 300 in the last line geom, which is x position to a variable %PosX for example. I tried already %PosX and %%PosX and even 'PosX'. Nothing works yet.

    PosX is set before creation, but the number doesn't go to the content of the buttons. I am not familiar with Java.

    Thats what I meant.

    Moreover, I have another problem, which I cannot solve and its pretty similar. I did another code and instead of interacting with Content like above, I moved buttons using Element -> Position, but first click creates both buttons, just the second click moves them together.
     
  5. CleTjB

    CleTjB Member
    Rank:
    None
    Points:
    36
    Posts:
    36
    Joined:
    Mar 26, 2012

    Mar 26, 2012
    36
    1
    36
    I'm trying to create just a simple 2 button prompt to ask if it should turn on Mobile Date On / Off buttons..
     

Share This Page

Loading...