2015-04-01 24 views
-1
PaginationLayout paginationLayout = new PaginationLayout(this); 
     paginationLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); 

    // creates content only for sample 
    TableLayout table = new TableLayout(this); 
    table.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); 
    table.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL); 

    TableRow row = new TableRow(this); 
    row.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); 
    table.addView(row); 

    TableRow row2 = new TableRow(this); 
    row2.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); 
    table.addView(row2); 

    for(int i = 0; i< 50;i++){ 
     Button button = new Button(this); 
     button.setText("Button " + i); 
     if (i%2==0) { 
      row.addView(button); 
     } else { 
      row2.addView(button); 
     } 
    } 

    // add the content in pagination 
    paginationLayout.addView(table); 
    // set pagination layout 
    setContentView(paginationLayout); 
} 
+0

歡迎計算器。請閱讀[如何提問](http://stackoverflow.com/help/how-to-ask) – Phate01 2015-04-01 12:25:35

回答

相關問題