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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:04:12+00:00 2026-05-27T17:04:12+00:00

I made a custom view to satisfy my need for an easy way to

  • 0

I made a custom view to satisfy my need for an easy way to display a mathematic vector.
I extended a LinearLayout and added an ArrayList for the values. Everytime the values change I call my custom method redraw() to add EditTexts to the LinearLayout. This way after adding a value, all existing EditTexts are added once again. How to I clear the LinearLayout or display a new LinearLayout?

Here some code:

public Vector(Context context, AttributeSet attrs) {
    super(context, attrs);
    setWillNotDraw(false);
    LayoutInflater inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    if (inflater != null) {
        inflater.inflate(R.layout.vector, this);
    }
}

public void redraw() {
    for (Float value : getArray()) {
        EditText edit = new EditText(getContext());
        edit.setLayoutParams(new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.FILL_PARENT));
        edit.setText(value.toString());

        ((LinearLayout) findViewById(R.id.root)).addView(edit);
    }
}
  • 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-05-27T17:04:13+00:00Added an answer on May 27, 2026 at 5:04 pm

    You can remove all views by using ((LinearLayout) findViewById(R.id.root)).removeAllViews().
    But why do you want to add all the edit text all over again if you can set the new values to the existing edit text views and add new view only if you still need to.
    I didn’t fully understand you.

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

Sidebar

Related Questions

I have a custom-made view that extends the View class. I would like 2
I made a custom view for a group of three tables. How would I
I made a custom component that extends View and overrides its onMeasure() , the
I had to populate a tree view for which i have made a custom
i made a custom view which should animate a dot on a background according
I made a very simply table view, with load more function. I have added
I have a custom view I made with an IB file since it's quite
I have a custom view I made with an IB file since it's quite
I've got a custom view in which I need to draw two bitmaps, one
I have made a custom view that I'm setting inside the onCreate() method in

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.