This may be a really stupid question, but I created such a structure and I really have performance problems.
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);
}
To be more spesific, it is very slow if I try to create 5 InnerClass objects and 5 InnerOfInner Class objects in each InnerClass. I would be extremely grateful if someone would explain to me why. thanks.
Iurii source share