Code example for AbsoluteLayout

Methods: addView

0
            } 
        }); 
    } 
 
    private void initLayout() { 
        AbsoluteLayout layout = new AbsoluteLayout(this);
 
        TextView lblAdress = new TextView(this);
        AbsoluteLayout.LayoutParams p = new AbsoluteLayout.LayoutParams(
                AbsoluteLayout.LayoutParams.WRAP_CONTENT, LINE_HEIGHT, INSETS, INSETS);
        lblAdress.setLayoutParams(p);
        lblAdress.setText("IP Address");
        layout.addView(lblAdress);
 
        TextView lblAccelerometer = new TextView(this);
        p = new AbsoluteLayout.LayoutParams(AbsoluteLayout.LayoutParams.WRAP_CONTENT, LINE_HEIGHT,
                INSETS, 3 * INSETS);
        lblAccelerometer.setLayoutParams(p);
        lblAccelerometer.setText("Accelerometer");
        layout.addView(lblAccelerometer);
 
        edtIpAddress = new EditText(this);
        edtIpAddress.setTextSize(12.0f);
        p = new AbsoluteLayout.LayoutParams(IP_WIDTH, AbsoluteLayout.LayoutParams.WRAP_CONTENT, 320
                - IP_WIDTH - INSETS, INSETS - 10);
        edtIpAddress.setLayoutParams(p);
        layout.addView(edtIpAddress);
 
        cbxAccelerometer = new CheckBox(this);
        cbxAccelerometer.setSelected(false);
        p = new AbsoluteLayout.LayoutParams(AbsoluteLayout.LayoutParams.WRAP_CONTENT,
                AbsoluteLayout.LayoutParams.WRAP_CONTENT, 320 - IP_WIDTH - INSETS, 3 * INSETS - 10);
        cbxAccelerometer.setLayoutParams(p);
        cbxAccelerometer.setOnCheckedChangeListener(this);
        layout.addView(cbxAccelerometer);
 
        setContentView(layout);
    } 
 
    /* 
Contextual code suggestions in your IDE  Get Codota for Java