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 7838275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:03:18+00:00 2026-06-02T15:03:18+00:00

public void onClick_addContact(View v) { LinearLayout layout = (LinearLayout) findViewById(R.id.layoutLinear); layout.addView(linearlayout(_intMyLineCount)); _intMyLineCount++; } private

  • 0
public void onClick_addContact(View v)
    {
            LinearLayout layout = (LinearLayout) findViewById(R.id.layoutLinear);
            layout.addView(linearlayout(_intMyLineCount));
            _intMyLineCount++;



    }


    private EditText editText(int _intID) {
            EditText editText = new EditText(this);
            editText.setId(_intID);
            editText.setHint("My lines");
            editText.setWidth(180);         

            editTextList.add(editText);
            return editText;
        }

       private TextView textView(int _intID)
        {
            TextView txtviewAll=new TextView(this);
            txtviewAll.setId(_intID);
            txtviewAll.setText("My lines:");        

            textviewList.add(txtviewAll);
            return txtviewAll;
        }

       private Button button(int _intID)
       {
           Button btn = new Button(this);
           btn.setId(_intID);
           btn.setTag("but1");
           btn.setOnClickListener(newContact);


           return btn;


       }

       OnClickListener newContact = new OnClickListener() {
                //onClick view
                public void onClick(View v) {


                    LinearLayout layout =  (LinearLayout)v.getParent();

                    layout.removeViewInLayout(v);
                   // setContentView(layout);

                        _intMyLineCount--;

                                    }

               };

       private LinearLayout linearlayout(int _intID)
        {
            LinearLayout LLMain=new LinearLayout(this);
            LLMain.setId(_intID);       
            LLMain.addView(textView(_intID));
            LLMain.addView(editText(_intID));
            LLMain.addView(button(_intID));
            LLMain.setOrientation(LinearLayout.HORIZONTAL);

            linearlayoutList.add(LLMain);
            return LLMain;

        } 

In the newOnContact Listener, only the child button gets deleted, but not the entire linear layout that includes the textView and EditText.
How to do it?

  • 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-02T15:03:19+00:00Added an answer on June 2, 2026 at 3:03 pm

    You can use layout.setVisibility(View.INVISIBLE); or
    layout.setVisibility(View.Gone); to remove the layout from UI.

    View.INVISIBLE will hide the view, but it’ll still take the space whereas View.GONE will remove the view as well as it won’t take up any space in the UI.

    Refer http://developer.android.com/reference/android/view/View.html#attr_android:visibility

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

Sidebar

Related Questions

private WebView wv; public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.infoweblinkview); wv=(WebView) findViewById(R.id.weblinkview); wv.setWebViewClient(new WebViewClient());
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button OpenPDF = (Button) findViewById(R.id.button); OpenPDF.setOnClickListener(new View.OnClickListener()
This is my code to add a new linear layout: public void onClick_addContact(View v)
So, I have a code: ((Button) findViewById(R.id.run)).setOnClickListener(new View.OnClickListener() { public void onClick(View v) {
ImageView connect = (ImageView) findViewById(R.id.fconnect); connect.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { facebook.authorize(SignIn.this,
Button novice = (Button) findViewById(R.id.novice); novice.setOnClickListener(new OnClickListener(){ public void onClick(View v) { Intent nov
private void setActionViewListener(final String uri) { mediaButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v)
public int testb; btn.setOnClickListener(new OnClickListener() { public void onClick(View v) { ********* }} How
Here is my code: private Button.OnClickListener gotologinpage3 = new Button.OnClickListener() { public void onClick(View
On my Main activity: button = (Button) findViewById(R.id.mainAddWatchButton); button.setOnClickListener(new Button.OnClickListener() { public void onClick(View

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.