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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:16:03+00:00 2026-06-13T10:16:03+00:00

Probably this is really stupid question but i created structure like this and i

  • 0

Probably this is really stupid question but i created structure like this and i really have issues with performance.

public class OuterClass extends LinearLayout {

private LinearLayout viewPort;

public OuterClass(Context context) {
    super(context);     
    initComponents(context);
    addInnerClass();
}

private void initComponents(Context context){

    LayoutInflater inflater = (LayoutInflater) getContext().
        getSystemService(Context.LAYOUT_INFLATER_SERVICE);      
    inflater.inflate(R.layout.view_port, this);     
    viewPort = (LinearLayout) findViewById(R.id.view_port);     
}

private void addInnerClass(){

    for ( int i = 0; i < k; i++ ){
        InnerClass functio = this.new InnerClass();
        viewPort.addView(functio);
    }

}
    private class InnerClass extends RelativeLayout{

    private LineraLayout newLines; 

    public InnerClass() {
        super(OuterClass.this.context);     
        initComponents(OuterClass.this.context);
        addNLines();
    }

    private void initComponents(Context context){

        LayoutInflater inflater = (LayoutInflater) getContext().
            getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        inflater.inflate(R.layout.job_function_container, this);

        newLines = (LinearLayout) findViewById(R.id.newLines);          

    }

    private void addInnerOfInner(View view){
        newLines.addView(view);
    }

    private void addNLines(){

        for ( int i = 0; i < k1; i++ ){
            InnerOfInnerClass line = this.new InnerOfInnerClass();
            addInnerOfInner(line);
        }

    }

        public class InnerOfInnerClass extends RelativeLayout{


            private InnerOfInnerClass(){
                super(OuterClass.this.context);             
                initComponents(OuterClass.this.context);
            }

            private void initComponents(Context context){

                LayoutInflater inflater = (LayoutInflater) getContext().
                    getSystemService(Context.LAYOUT_INFLATER_SERVICE);

                inflater.inflate(R.layout.new_line, this);

                // Setting some fields.
            }               

        }   

    }

}

To be more spesific it is realy slow if i will try to create 5 InnerClass objects and 5 of InnerOfInner Class objects in each InnerClass. I would be extremely grateful if some one will explain me why. Thx.

  • 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-13T10:16:04+00:00Added an answer on June 13, 2026 at 10:16 am

    There doesn’t seem to be anything that stands out from your code as a huge red flag. As to why it’s really slow in the creation part could be for a variety of reasons. Things to consider:

    1. How is OuterClass being instantiated from the activity? Is it only being called once or are you creating several instances. The more you have the slower it’ll be.

    2. How many other widgets are on the R.layout.new_line, R.layout.job_function_container, R.layout.view_port? Having just one widget vs 50 on each may cause some noticeable delays.

    3. What device are you testing with? Running on a old Droid will be significantly slower then testing on a Nexus 7. If your using an emulator…well, always expect everything to run slow.

    4. Finally (and probably the most pertinent), I believe the biggest slow down is the complexity or the depth of your nesting layouts. As Ancantus mentioned, try to avoid deep layout layers. Go too deep, and weird things may start to happen. Mostly due to the amount of memory such hierarchies consume.

    If you need a dynamic means of adding views, I’d suggest looking into a ListView, GridView, or even a GridLayout if your target platform allows. Off the top of my head, I can’t think of why you would require such a complex design. Though there are special case needs, usually there’s always an easier, more correct way.

    Here’s some helpful links on Layout Optimization that may or may not be helpful for you:

    • Layout Trick 1
    • Layout Trick 2
    • Layout Trick 3
    • Layout Trick 4
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably a really stupid MSBuild question but if I have <ItemGroup> <Dll
This probably sounds like a stupid question, but I'm going to give it a
This is probably a really stupid question but I can't figure this out. I
This is probably a really stupid question, but how do I turn on these
Ok. This is probably a really stupid question, but I'm going to ask it
Sorry, this is probably a really stupid question, but is it safe to run
This is probably a stupid question, but I'm really struggling with this concept. I'm
This is probably a really stupid newbie-sounding question to you developer type people, but
This probably sounds really stupid but I have noo idea how to implement jquery's
this is probably a really stupid question, but I am big R newbie and.

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.