Android - 動態增加 View

摘要:Android - 動態增加 View

LinearLayout layout = (LinearLayout)findViewById(R.id.rootLayout);
 
TextView tv = new TextView(this);
tv.setText("Hello World");
 
layout.addView(tv, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);