public class Test extends Activity {
/** Called when the activity is first created. */
private TableLayout tl;
private TableRow tr;
private TableLayout.LayoutParams tlparams;
private TableRow.LayoutParams trparams;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout ll = new LinearLayout(this);
LinearLayout.LayoutParams llparams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.FILL_PARENT);
ll.setLayoutParams(llparams);
ll.setBackgroundColor(Color.WHITE);
tl = new TableLayout(this);
tlparams = new TableLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
tl.setLayoutParams(tlparams);
tr = new TableRow(this);
trparams = new TableRow.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
tr.setLayoutParams(trparams);
// setHeader();
// setHeader1();
setData1();
setContentView(tl);
}
private void setData1() {
String[] data1 = new String[] { "1부문","남성복","계", "17.4", "18.3", "-0.9",
"1부문","남성복","a", "19.9", "19.7", "0.2",
"1부문","남성복","b", "16.5", "17.8", "-1.3",
"1부문","남성복","c", "12.0", "14.5", "-2.5",
"1부문","남성복","d", "19.9", "19.7", "0.2",
"1부문","남성복","e", "16.5", "17.8", "-1.3",
"1부문","남성복","f", "12.0", "14.5", "-2.5",
"1부문","남성복","g", "19.9", "19.7", "0.2",
"1부문","남성복","h", "16.5", "17.8", "-1.3",
"1부문","여성복","계", "17.4", "18.3", "-0.9",
"1부문","여성복","ㄱ", "19.9", "19.7", "0.2",
"1부문","여성복","ㄴ", "16.5", "17.8", "-1.3",
"1부문","여성복","ㄷ", "12.0", "14.5", "-2.5",
"1부문","여성복","ㄹ", "19.9", "19.7", "0.2",
"1부문","여성복","ㅁ", "16.5", "17.8", "-1.3",
"1부문","여성복","ㅂ", "12.0", "14.5", "-2.5",
"1부문","여성복","ㅅ", "19.9", "19.7", "0.2",
"1부문","아동복","계", "17.4", "18.3", "-0.9",
"1부문","아동복","A", "19.9", "19.7", "0.2",
"1부문","아동복","B", "16.5", "17.8", "-1.3" };
TableRow tr1 = null;
TextView[] text1 = new TextView[data1.length];
for (int i = 0; i < data1.length; i++) {
if(i%6==0) {
tr1 = new TableRow(this);
tr1.setLayoutParams(trparams);
text1[i] = new TextView(this);
text1[i].setText(data1[i]);
tr1.addView(text1[i]);
} else if (i%6==5) {
text1[i] = new TextView(this);
text1[i].setText(data1[i]);
tr1.addView(text1[i]);
tl.addView(tr1);
} else {
text1[i] = new TextView(this);
text1[i].setText(data1[i]);
//if(i==1) {text1[i].
tr1.addView(text1[i]);
}
}
}
xml 없이 자바소스로만 되어 있구요
위의 결과값은 첨부파일 왼쪽의 그림처럼 출력되요
왼쪽의 X표시가 되어 있는 이미지요..
근데 저는 오른쪽의 O표시가 되어 있는 이미지처럼 출력되기를 원하는데
rowspan, colspan 이런걸 잘 응용하면 될 것 같은데
자바소스로 어떻게 써야하는지 도저히 모르겠네요 ㅠㅠㅠㅠ
여기서 어떻게 추가를 해야 제가 원하는 것처럼 출력할 수 있을까요????
layout_span 이걸 잘 응용하면 될 것 같은데....
ctrl+space를 눌러도 마땅한 메소드가 없는 것 같아요
조언 좀 부탁드려요...