FileDocCategorySizeDatePackage
VerticalFocusSearch.javaAPI DocAndroid 5.1 API4395Thu Mar 12 22:22:12 GMT 2015android.widget.focus

VerticalFocusSearch

public class VerticalFocusSearch extends android.app.Activity
Holds a few buttons of various sizes and horizontal placements in a vertical layout to excercise some core focus searching.

Fields Summary
private android.widget.LinearLayout
mLayout
private android.widget.Button
mTopWide
private android.widget.Button
mMidSkinny1Left
private android.widget.Button
mBottomWide
private android.widget.Button
mMidSkinny2Right
Constructors Summary
Methods Summary
private android.widget.ButtonaddSkinny(android.widget.LinearLayout root, java.lang.String label, boolean atRight)
Add a skinny button that takes up just less than half of the screen horizontally.

param
root The layout to add the button to.
param
label The label of the button.
param
atRight Which side to put the button on.
return
The newly created button.

        Button button = new MyButton(this);
        button.setText(label);
        button.setLayoutParams(new LinearLayout.LayoutParams(
                0, // width
                ViewGroup.LayoutParams.WRAP_CONTENT,
                480));

        TextView filler = new TextView(this);
        filler.setText("filler");
        filler.setLayoutParams(new LinearLayout.LayoutParams(
                0, // width
                ViewGroup.LayoutParams.WRAP_CONTENT,
                520));

        LinearLayout ll = new LinearLayout(this);
        ll.setOrientation(LinearLayout.HORIZONTAL);
        ll.setLayoutParams(new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

        if (atRight) {
            ll.addView(filler);
            ll.addView(button);
            root.addView(ll);
        } else {
            ll.addView(button);
            ll.addView(filler);
            root.addView(ll);
        }
        return button;
    
public android.widget.ButtongetBottomWide()

        return mBottomWide;
    
public android.widget.LinearLayoutgetLayout()

        return mLayout;
    
public android.widget.ButtongetMidSkinny1Left()

        return mMidSkinny1Left;
    
public android.widget.ButtongetMidSkinny2Right()

        return mMidSkinny2Right;
    
public android.widget.ButtongetTopWide()

        return mTopWide;
    
private android.widget.ButtonmakeWide(java.lang.String label)

        Button button = new MyButton(this);
        button.setText(label);
        button.setLayoutParams(new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        return button;
    
protected voidonCreate(android.os.Bundle icicle)

        super.onCreate(icicle);

        mLayout = new LinearLayout(this);
        mLayout.setOrientation(LinearLayout.VERTICAL);
        mLayout.setHorizontalGravity(Gravity.START);
        mLayout.setLayoutParams(new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));

        mTopWide = makeWide("top wide");
        mLayout.addView(mTopWide);

        mMidSkinny1Left = addSkinny(mLayout, "mid skinny 1(L)", false);

        mMidSkinny2Right = addSkinny(mLayout, "mid skinny 2(R)", true);

        mBottomWide = makeWide("bottom wide");
        mLayout.addView(mBottomWide);

        setContentView(mLayout);