FileDocCategorySizeDatePackage
LinearLayout8.javaAPI DocGoogle Android v1.5 Example3574Sun Nov 11 13:01:04 GMT 2007com.google.android.samples.view

LinearLayout8

public class LinearLayout8 extends android.app.Activity
Demonstrates horizontal and vertical gravity

Fields Summary
private android.widget.LinearLayout
mLinearLayout
public static final int
VERTICAL_ID
public static final int
HORIZONTAL_ID
public static final int
TOP_ID
public static final int
MIDDLE_ID
public static final int
BOTTOM_ID
public static final int
LEFT_ID
public static final int
CENTER_ID
public static final int
RIGHT_ID
Constructors Summary
Methods Summary
protected voidonCreate(android.os.Bundle icicle)


    
        
        super.onCreate(icicle);
        setContentView(R.layout.linear_layout_8);
        mLinearLayout = (LinearLayout)findViewById(R.id.layout);
    
public booleanonCreateOptionsMenu(android.view.Menu menu)

        super.onCreateOptionsMenu(menu);
        menu.add(0, VERTICAL_ID, R.string.linear_layout_8_vertical);
        menu.add(0, HORIZONTAL_ID, R.string.linear_layout_8_horizontal);
        menu.addSeparator(0, 0);
        menu.add(0, TOP_ID, R.string.linear_layout_8_top);
        menu.add(0, MIDDLE_ID, R.string.linear_layout_8_middle);
        menu.add(0, BOTTOM_ID, R.string.linear_layout_8_bottom);
        menu.addSeparator(0, 0);
        menu.add(0, LEFT_ID, R.string.linear_layout_8_left);
        menu.add(0, CENTER_ID, R.string.linear_layout_8_center);
        menu.add(0, RIGHT_ID, R.string.linear_layout_8_right);

        return true;
    
public booleanonOptionsItemSelected(Menu.Item item)

        switch (item.getId()) {

        case VERTICAL_ID:
            mLinearLayout.setOrientation(LinearLayout.VERTICAL);
            return true;
        case HORIZONTAL_ID:
            mLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
            return true;

        case TOP_ID:
            mLinearLayout.setVerticalGravity(Gravity.TOP);
            return true;
        case MIDDLE_ID:
            mLinearLayout.setVerticalGravity(Gravity.CENTER_VERTICAL);
            return true;
        case BOTTOM_ID:
            mLinearLayout.setVerticalGravity(Gravity.BOTTOM);
            return true;

        case LEFT_ID:
            mLinearLayout.setHorizontalGravity(Gravity.LEFT);
            return true;
        case CENTER_ID:
            mLinearLayout.setHorizontalGravity(Gravity.CENTER_HORIZONTAL);
            return true;
        case RIGHT_ID:
            mLinearLayout.setHorizontalGravity(Gravity.RIGHT);
            return true;

        }
        return super.onOptionsItemSelected(item);