19
에 TableRow을 추가는 동적으로 버튼을 클릭하면, 다음과 같은 방법을 실행 TableLayout을
public void createTableRow(View v) {
TableLayout tl = (TableLayout) findViewById(R.id.spreadsheet);
TableRow tr = new TableRow(this);
LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
tr.setLayoutParams(lp);
TextView tvLeft = new TextView(this);
tvLeft.setLayoutParams(lp);
tvLeft.setBackgroundColor(Color.WHITE);
tvLeft.setText("OMG");
TextView tvCenter = new TextView(this);
tvCenter.setLayoutParams(lp);
tvCenter.setBackgroundColor(Color.WHITE);
tvCenter.setText("It");
TextView tvRight = new TextView(this);
tvRight.setLayoutParams(lp);
tvRight.setBackgroundColor(Color.WHITE);
tvRight.setText("WORKED!!!");
tr.addView(tvLeft);
tr.addView(tvCenter);
tr.addView(tvRight);
tl.addView(tr, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
}
R.id.spreadsheet
는 XML TableLayout을합니다. 디버깅을 통해 메소드에 액세스하고 있지만 화면에는 아무 것도 표시되지 않습니다. 뭐라 구요? 콘텐츠 뷰를 어떻게 재설정해야합니까?
이러한 뷰의 정렬, 여백 및 배치를 설정할 수 있습니까? –