Android Question LOAD OR DISPLAY A LAYOUT IN A LOOP

PabloA

Member
Hola, buenas noches, soy nuevo en la programación de Android. Mi pregunta es la siguiente, estoy haciendo una aplicación para mostrar un diseño en bucle, pero cuando ejecuto el programa no se detiene en el primer valor sino que pasa y muestra el diseño hasta el último valor.
Cualquier colaboración se agradece de antemano.


Sub Activity_Create (primera vez como booleano)
Para i=1 a 3
Activity.LoadLayout("tramos")
Label4.Text="TRAMO" & yo

próximo
 

edgar_ortiz

Active Member
Licensed User
Longtime User
Hola, buenas noches, soy nuevo en la programación de Android. Mi pregunta es la siguiente, estoy haciendo una aplicación para mostrar un diseño en bucle, pero cuando ejecuto el programa no se detiene en el primer valor sino que pasa y muestra el diseño hasta el último valor.
Cualquier colaboración se agradece de antemano.


Sub Activity_Create (primera vez como booleano)
Para i=1 a 3
Activity.LoadLayout("tramos")
Label4.Text="TRAMO" & yo

próximo
Si vas a poner un mensaje en el foro en ingles, te aconsejo que utilices lo traduzca al ingles.

Solo por cortesia

(If you are going to put a message in the forum in English, I advise you to use translate it to English.

just for courtesy)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
This is the english part of the forum. Please write english here.

Alternatively you can create a thread in the spanish/portuguese forum if you want to talk in your language.

Note that your loop adds the same label on each iteration. Means you overwrite the last added label with a new one. Only the last one is accessible.

If you need 3 Labels of the same position you need to add them to a panel, add the panel to the activity and load the layout on each of the Panels.

B4X:
    For i=1 To 3
        Dim pnl As Panel = xui.CreatePanel("PNL")
        Activity.AddView(pnl,0,i*50dip,100%x,100dip)
        pnl.LoadLayout("Layout")
        Label4.Text="TRAMO" & i
    Next

WhatsApp Image 2022-04-16 at 10.35.18.jpeg
 
Last edited:
Upvote 2

PabloA

Member
Good morning, I apologize for the mistakes made in my question and thank you for the response and comments.
Well I'm going to try the solution that indicates me and see how it goes.
 
Upvote 0
Top