» 首頁 » 討論區 » Android程式設計 »動態置入View

動態置入View

發表人: Seachaos
積分: 2432
發表時間: 2009-11-19 07:55:37
以下是Android動態加入View到Layout的方法
這個好處是可以於程式執行時放入View元件,比起修改xml的方式來的方便
[quote]
        LinearLayout LL = (LinearLayout)findViewById(R.id.display_area);

        TextView textview = new TextView(this);        
        textview.setText("Good");
        textview.setTextSize(22);
        textview.setTextColor(Color.BLACK);

        LL.addView(textview);
[/quote]