Code example for TableLayout

Methods: addView, setBackgroundColor

0
 
        super.test = "bbb"; 
    	super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
         
        TableLayout tableLayout = new TableLayout(this);
        tableLayout.setBackgroundColor(Color.rgb(255, 255, 255));
        setContentView(tableLayout, new LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.FILL_PARENT));
 
        TableRow tableRow1 = new TableRow(this);
        userId=new EditText(this);
        userId.setText("userId", EditText.BufferType.NORMAL);
//        userId.setFilters(filters); 
        TableRow.LayoutParams rowLayout = new TableRow.LayoutParams();
        rowLayout.span = 2;
        tableRow1.addView(userId,rowLayout);
         
        TableRow tableRow2 = new TableRow(this);
        passwd=new EditText(this);
        passwd.setText("passwd", EditText.BufferType.NORMAL);
        passwd.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
        tableRow2.addView(passwd, rowLayout);
         
        TableRow tableRow3 = new TableRow(this);
        //�nK�{�^���̐��� 
        okBtn = new Button(this);
        okBtn.setText("OK");
        okBtn.setOnClickListener(this);
        okBtn.setTag("ok");
        tableRow3.addView(okBtn);
         
        //CANCEL�{�^���̐��� 
        cancelBtn = new Button(this);
        cancelBtn.setText("CANCEL");
        cancelBtn.setOnClickListener(this);
        cancelBtn.setTag("cancel");
        tableRow3.addView(cancelBtn);
         
        //���[�U�쐬�{�^���̐��� 
        newBtn = new Button(this);
        newBtn.setText("�V�K�쐬");
        newBtn.setOnClickListener(this);
        newBtn.setTag("new");
        tableRow3.addView(newBtn);
 
        tableLayout.addView(tableRow1);
        tableLayout.addView(tableRow2);
        tableLayout.addView(tableRow3);
    } 
     
    public void onClick(View v) {
    	try { 
	    	String tag = (String)v.getTag();