2013-08-23 78 views
0

這是我的代碼的一部分,必須顯示幾個項目的表視圖,但它沒有顯示任何東西。不顯示TableView的項目

​​

什麼問題? 感謝

+0

只有一個錶行應顯示在屏幕上。所有爲表格佈局調用refreshDrawableState()。 – Sumant

+0

感謝您的迴應,但我沒有看到任何行,只有白色屏幕。我該如何解決這個問題? –

+0

只是嘗試替換tableView.addView(tr,new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));與tableView.addView(tr,320,50);暫時如果你看到屏幕上的行,這意味着你需要改變參數。也給一些顏色的表格行像藍色/紅色,這樣你就可以識別 – Sumant

回答

1

嘗試:name.setTextColor(Color.BLACK);

+0

謝謝,但它沒有幫助(( –

+0

@HaykNahapetyan嘗試不設置任何佈局參數。這有時爲我工作.. –

+0

它didn'再次幫助((但是,我會upvote你的答案,非常感謝你 –

0

試試這個代碼

TableLayout tl = (TableLayout) findViewById(R.id.tableLayoutUsers); 

    TableRow tr = new TableRow(this); 
    tr.setId(100 + 0); 

    TableLayout.LayoutParams params = new TableLayout.LayoutParams(
      TableLayout.LayoutParams.WRAP_CONTENT, 
      TableLayout.LayoutParams.WRAP_CONTENT, 1f); 

    TextView text = new TextView(this); 
    text.setText("Meenal"); 
    text.setTextColor(Color.BLACK); 

    TableRow.LayoutParams imageParams = new TableRow.LayoutParams(); 

    tr.addView(text); 

    tr.setLayoutParams(params); 
    tl.addView(tr, params);