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

  • SEARCH
  • Home
  • 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 8623471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:17:19+00:00 2026-06-12T07:17:19+00:00

i already asked question (http://stackoverflow.com/questions/12663443/add-delete-option-with-dynamically-generated-edittext). I successfully implemented the answer,but the issue with this

  • 0

i already asked question (http://stackoverflow.com/questions/12663443/add-delete-option-with-dynamically-generated-edittext). I successfully implemented the answer,but the issue with this code is textEdit, spinner and the remove button together is not removing from the view. It happens but i have to made three button click to happen this .. Please go through my code .

 btnAddNew.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            LinearLayout rAlign = (LinearLayout)findViewById(R.id.lId);
            final EditText newPass = new EditText(getApplicationContext());
            allEds.add(newPass);
            newPass.setHint("Name of Label");
            newPass.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            //newPass.setWidth(318);
            newPass.setTextColor(Color.parseColor("#333333"));
            newPass.setId(MY_BUTTON);
             System.out.println(MY_BUTTON);  
            //newPass.setOnClickListener(this);
            rAlign.addView(newPass);

            addSpinner();//Code to add spinner              
            Button btnRemoveOld = new Button(getApplicationContext());
            btnRemoveOld.setId(MY_BUTTON); // arbitrary number
            rAlign.addView(btnRemoveOld);
            btnRemoveOld.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    int idf =MY_BUTTON -1;
                    LinearLayout rAlign = (LinearLayout)findViewById(R.id.lId);
                    rAlign.removeView(findViewById(idf));
                  allEds.remove(newPass);

                }
            }); 
           MY_BUTTON ++;
        } 
    });
  • 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-12T07:17:20+00:00Added an answer on June 12, 2026 at 7:17 am

    If you use MY_BUTTON to assign an ID for each View

    newPass.setId(MY_BUTTON); 
    MY_BUTTON++;
    spinner.setId(MY_BUTTON);
    MY_BUTTON++;
    btnRemoveOld.setId(MY_BUTTON);
    MY_BUTTON++;
    

    You could do this in the btnRemoveOld’s onClickListner to remove all three objects

    btnRemoveOld.setOnClickListener(new OnClickListener() {
                  public void onClick(View v) {
                      //gets the ID of the btnRemoveOld;
                      int idf =v.getId();
                      LinearLayout rAlign = (LinearLayout)findViewById(R.id.lId);
                      //will return the newPass button
                      rAlign.removeView(findViewById(idf-2));
                      //will return the spinner
                      rAlign.removeView(findViewById(idf-1));
                      //will remove the btnRemoveOld
                      rAlign.removeView(v);
                        }
              });
    

    By doing v.getId(), you’re getting the id value of the btnRemoveOld and from the code you’ve assured yourself that the spinner is the id-1 and that the newPass button is the id-2.

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

Sidebar

Related Questions

I'm asking the same question here that I've already asked on msdn forums http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/70f40a4c-8399-4629-9bfc-146524334daf
I was asked to post this as a question on StackOverflow by http://twitter.com/jonathanjulian which
I already asked the same question over at dev.twitter.com , however, I didn't get
I´ve already asked this question at the comment section of the tutorial-site http://tympanus.net/codrops/2011/10/12/flexible-slide-to-top-accordion/ I
Please refer to my question asked at tek-tips.com: http://tek-tips.com/viewthread.cfm?qid=1663735&page=1 As I mentioned in a
I have tried looking though several of the already asked question about this topic
I already asked this question but at that time I tought that the refresh
I've already asked this question on several forums, but without any good explanation of
I am sorry I have already asked this question on Superuser, but nobody answers
I already asked a similar question, PE Header requirements , but I'm not really

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.