FileDocCategorySizeDatePackage
LinearLayout8.javaAPI DocAndroid 1.5 API3604Wed May 06 22:41:08 BST 2009com.example.android.apis.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 savedInstanceState)


    
        
        super.onCreate(savedInstanceState);
        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, 0, R.string.linear_layout_8_vertical);
        menu.add(0, HORIZONTAL_ID, 0, R.string.linear_layout_8_horizontal);
        menu.add(0, TOP_ID, 0, R.string.linear_layout_8_top);
        menu.add(0, MIDDLE_ID, 0, R.string.linear_layout_8_middle);
        menu.add(0, BOTTOM_ID, 0, R.string.linear_layout_8_bottom);
        menu.add(0, LEFT_ID, 0, R.string.linear_layout_8_left);
        menu.add(0, CENTER_ID, 0, R.string.linear_layout_8_center);
        menu.add(0, RIGHT_ID, 0, R.string.linear_layout_8_right);

        return true;
    
public booleanonOptionsItemSelected(android.view.MenuItem item)

        switch (item.getItemId()) {

        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);