1
activity
ではない別のクラスにlayout
をプログラムで作成したいので、アクティビティから1つの関数を呼び出し、レイアウトを作成するためのすべてのコードが機能します。だから、コードを書いてみてください。別のクラスのアクティビティレイアウトを作成
これが私の活動です:
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);
}
}
そして、これは、プログラムでレイアウトを生成している機能を持っている私のクラスである:
public class testing {
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);
}
}
は、私がこれを行うか、私を助けてくださいことはできません。