0
我想單擊按鈕時動態添加文本視圖。我已經實現了這一點,但添加它時,通過編寫以前的one.Any錯我的代碼?動態添加多個佈局android
imGbtn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
int id =0;
final String data = textView.getText().toString();
//childHolder.title.setText(data);
LinearLayout ll = new LinearLayout(mContext);
ll.setOrientation(LinearLayout.VERTICAL);
ll.setId(id);
tvll.addView(ll);
// TextView tv1 = new TextView(mContext);
// tv1.setText("Dynamic layouts ftw!");
// ll.addView(tv1);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
layoutParams.setMargins(25, 20, 25, 10);
TextView tv= new TextView(mContext);
tv.setId(id);
tv.setText(data);
ll.addView(tv,layoutParams);
textView.setText("");
}
});