Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8937431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:24:50+00:00 2026-06-15T10:24:50+00:00

I have multiple views create using a loop its a button and a textview

  • 0

I have multiple views create using a loop its a button and a textview actually, how do you remove one of them using id?

for i=1,#displaymovenames do
    moveButton = widget.newButton {
                default = "closeBox.png",
                over = "openBox.png",
                width = 50,
                height = 50,
                onRelease = startMove,
                id = moveID
                }
            moveButton.x = 50; moveButton.y = boxy

    local deletemove = widget.newButton{
        default = "remove.png",
        over = "removeOver.png",
        width = 30,
        height = 30,
        id = moveID,
        alpha = 0,
        onRelease = deleteSelectedItem
        }
    deletemove.x = _W + 20; deletemove.y = deletey

        t = display.newText(displaymovenames[i], 85, texty, native.systemFont , 13)
        t:setTextColor( 0, 0, 0)
        t.id = moveID

        boxy = boxy + 65
        texty = texty + 65
        deletey = deletey + 65
        moveID = moveID + 1
        moveitemscroll:insert ( moveButton )
        moveitemscroll:insert ( t )
        deletemoveGroup:insert ( deletemove )
end

well basically what this code does is that when the deletemove button is pressed the moveButton, deletemove and t are remove this is the function responsible for the remove:

deleteSelectedItem = function ( event )
   event.target:removeSelf()
end

as you can see I am only able to remove the view that is being pressed how about the other view that are being pressed? how can i remove them? can i use id right? if yes how?

Edit

What i just wanted to do is this. Think of this items below as view.

  ------       -------------       -------
 |image1|     |anotherimage1|     |button1|
  ------       -------------       -------

  ------       -------------       -------
 |image2|     |anotherimage2|     |button2|
  ------       -------------       -------

  ------       -------------       -------
 |image3|     |anotherimage3|     |button3|
  ------       -------------       -------

  ------       -------------       -------
 |image4|     |anotherimage4|     |button4|
  ------       -------------       -------

when button1 is press button1, image1 and anotherimage1 is remove from the view and so on.

I can accomplish this if I just place them in a group the problem is that the buttons are already assigned to a different group. Is there any other way to solve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:24:51+00:00Added an answer on June 15, 2026 at 10:24 am

    I’m not a fan of UI library, and I would probably use a table to store the buttons, but I think you can do this:

    Inside the for loop:

    deletemove.moveButton = moveButton
    deletemove.t = t
    

    The function:

    deleteSelectedItem = function ( event )
       event.target.moveButton:removeSelf()
       event.target.t:removeSelf()
       event.target:removeSelf()
       -- remove listeners and nil the objects to avoid memory leaks.
    end
    

    Hope this works

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got some Oracle-Views which I'm using to generate multiple Letters. For Example: CREATE
I have a for loop that creates multiple UIImageViews that I add to self.view
In my iPad Application I have multiple views on a screen. What I want
Is it considered bad practice to have multiple views for same URL in MVC,
I have a view that has multiple views inside it, and an image presentation
I have a MVVM application that contains multiple views with some complex IsReadOnly rules
I have a very large script which is creating multiple views. In a number
I am have an issue with my scrollview which holds multiple views. I think
I have used multiple activities to handle mutiple views in android . I found
Possible Duplicate: Multiple index variables in PHP foreach loop I am trying to create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.