0
I'am는 배수 it.My 코드에서 레이아웃을 infalted 된 TableRow를 만들려고하기 위해 약 2 시간 동안 갇혀에 프로그래밍 방식으로 TableRow 할 수는 다음과 같습니다addView for 루프
LayoutInflater inflater = LayoutInflater.from(this);
TableLayout tblLayout = inflater.inflate(R.layout.tblL,parent,false);
TableRow tableRow = (TableRow) tblListItems.findViewById(R.id.tableRow);
View headerCell = inflater.inflate(R.layout.header_col,tblListItems,false);
TextView tvCellName = (TextView) headerCell.findViewById(R.id.tvCellName);
for(String item: items) {
tvCellName.setText(item);
tableRow.addView(tvCellName);
}
relativeLayout2.addView(tblLayout);
오류 I을 잘못은 무엇을 I'am
The specified child already has a parent. You must call removeView() on the child's parent first.
을 나는 그것을 바로 방법을 수행해야 얻을?
문제는 내 TextVi ew는 부풀려진 레이아웃에서 나올 필요가 있습니다. 'TextView tvCellName = (TextView) headerCell.findViewById (R.id.tvCellName); ' – TGeorge
보기를 동적으로 만들어야합니다. 너의 문제는 그렇지 않아. 문제는 뷰 **를 여러 번 추가 할 수 없다는 것입니다. –
죄송합니다. 것은'tvCellName'을'tableRow'에 추가 할 필요가 없다는 것입니다. 테이블 행에'TextView'가있는'headerCell'을 추가해야합니다. – TGeorge