Making activity layout in another class
<p>I want to create layout programmatically in different class which is not an activity so i will call one function from Activity and all code for creating layout is in function. so please give me some idea to write code.</p>

<p>this is my Acitivity:</p>

<p>public class Main extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        TableLayout tl = (TableLayout) findViewById(R.id.table1);
        testing t1 = new testing();
        Main m = new Main();
       t1.makelayout(tl,m); 
    }
}</p>

<p>and this is my class which has function that is generating layout programmatically:</p>

<p>public class testing {</p>

<pre><code>public void makelayout(TableLayout tl,Main m1) {
    // TODO Auto-generated method stub
    //Main m = new Main();
     TextView tv= new TextView(m1);
      tv.setText("hello1");
      tl.addView(tv);  
}
</code></pre>

<p>}</p>

<p>can i do this or not please help me.</p>
