看看代碼片斷波紋管是爲Android爲什麼添加的視圖沒有出現在屏幕上?
TableLayout tbL = (TableLayout) findViewById(R.id.moreInfo_table);
tbL.addView(getRow(key, value), new TableLayout.LayoutParams
(TableLayout.LayoutParams.FILL_PARENT,TableLayout.LayoutParams.WRAP_CONTENT));
private TableRow getRow(String key, String value) {
TableRow tbR = new TableRow(this);
try {
TextView keyTV = new TextView(this);
keyTV.setText("Key ");
keyTV.setTextColor(Color.WHITE);
keyTV.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
keyTV.setTextSize(18.0F);
TextView valueTV = new TextView(this);
valueTV.setText("Value ");
valueTV.setTextColor(Color.WHITE);
valueTV.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
valueTV.setTextSize(18.0F);
tbR.addView(keyTV,new TableLayout.LayoutParams
(TableLayout.LayoutParams.WRAP_CONTENT,TableLayout.LayoutParams.WRAP_CONTENT));
tbR.addView(valueTV,new TableLayout.LayoutParams
(TableLayout.LayoutParams.WRAP_CONTENT,TableLayout.LayoutParams.WRAP_CONTENT));
} catch (Exception e) {
e.printStackTrace();
}
return tbR;
}
問題出在哪裏??????!
你有沒有的setContentView()的活動? xml文件中moreInfo_table的佈局參數是什麼?最好的祝福。 – pouzzler 2012-04-10 16:30:50
'' 但它的主要內容是針對BART –
2012-04-10 16:41:56