Code example for TableRow

Methods: getChildCount, setLayoutParams

0
                1.0f); 
        TableLayout.LayoutParams rowLp = new TableLayout.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.FILL_PARENT,
                1.0f); 
        TableRow tableRow = new TableRow(activity);
        tableRow.setLayoutParams(rowLp);
        for(int i=1;i<= Constants.NUMBER_OF_LEVELS;i++)
        { 
            Button button = new Button(this);
            button.setText("Level " + i);
            final int j = i;
            button.setOnClickListener(new View.OnClickListener() {
                @Override 
                public void onClick(View view) {
                    Intent myIntent3 = new Intent(activity, RunnerLevels.class);
                    levelFacade.setCurrentLevel(j);
                    levelFacade.setBeginLevelPoints(0);
                    levelFacade.setCurrentPoints(0);
                    activity.startActivity(myIntent3);
                } 
            }); 
            button.setId(i);
            buttons.add(button);
            tableRow.addView(buttons.get(i-1), cellLp);
            if(i%3==0)
            { 
                llinner.addView(tableRow);
                tableRow = new TableRow(this);
            } 
        } 
        if(tableRow.getChildCount()>0)
        { 
            llinner.addView(tableRow);
        } 
 
    } 
Experience pair programming with AI  Get Codota for Java