2013-02-12 24 views
0

我有這樣的事情:動態地在分隔的文件添加行TableLayout

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <TableLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 

     <TableRow 
      android:id="@+id/tableRow1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"> 

      <TextView 
       android:id="@+id/chooseBirthDateText" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="25dp" 
       style="@style/mediumText" 
       android:gravity="center_horizontal" 
       android:text="@string/choose_birth_date" /> 

     </TableRow> 
    </TableLayout> 
</ScrollView> 

我想補充一些行,但只有經過一段時間後(可以說10秒)。我想先讓這些行不可見,然後讓它們出現。但在這種方式我的scrollView不工作,因爲我想(我可以向下滾動,即使沒有下面的任何東西 - 因爲行是不可見的)

所以我想做的行,我想添加到第二個文件,加載它們中間時間並在他們必須出現的時刻將它們添加到tableRow1之後。不幸的是我有不知道怎麼做,(我說的是連接2個文件,而不是使用Java創建第二個):/

回答

0

你應該這樣試試。我知道它有幫助嗎?

for(int i = 0; i < _attributeList.size();i++){ 


     TableRow newRow = new TableRow(getApplicationContext()); 
     newRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT)); 

     newCheckBox = new CheckBox(getApplicationContext()); 

       TextView feeTypeText = new TextView(getApplicationContext()); 
       feeTypeText.setText(jsonObj.getString("feeType")); 
       feeTypeText.setTextColor(Color.BLACK); 
       feeTypeText.setTextSize(16f); 
       feeTypeText.setTypeface(tf); 

       TextView dueAmountText = new TextView(getApplicationContext()); 
       dueAmountText.setText(jsonObj.getString("dueAmount")); 
       dueAmountText.setTextColor(Color.BLACK); 
       dueAmountText.setTextSize(16f); 
       dueAmountText.setTypeface(tf); 

       TextView dueDateText = new TextView(getApplicationContext()); 
       dueDateText.setText(jsonObj.getString("dueDate")); 
       dueDateText.setTextColor(Color.BLACK); 
       dueDateText.setTextSize(16f); 
       dueDateText.setTypeface(tf); 

       newRow.addView(newCheckBox,(new LayoutParams(0,LayoutParams.WRAP_CONTENT,0.8f))); 
       newRow.addView(feeTypeText,(new LayoutParams(0,LayoutParams.WRAP_CONTENT,0.8f))); 
       newRow.addView(dueAmountText,(new LayoutParams(0,LayoutParams.WRAP_CONTENT,1.0f))); 
       newRow.addView(dueDateText,(new LayoutParams(0,LayoutParams.WRAP_CONTENT,1.0f))); 

attributeTable.addView(newRow); }