FileDocCategorySizeDatePackage
Dots.javaAPI DocAndroid 1.5 API2511Wed May 06 22:42:42 BST 2009com.android.browser

Dots

public class Dots extends android.widget.LinearLayout
Displays a series of dots. The selected one is highlighted. No animations yet. Nothing fancy.

Fields Summary
private static final int
MAX_DOTS
private int
mSelected
Constructors Summary
public Dots(android.content.Context context)


       
        this(context, null);
    
public Dots(android.content.Context context, android.util.AttributeSet attrs)

        super(context, attrs);

        setGravity(Gravity.CENTER);
        setPadding(0, 4, 0, 4);

        LayoutParams lp =
                new LayoutParams(LayoutParams.WRAP_CONTENT,
                                 LayoutParams.WRAP_CONTENT);

        for (int i = 0; i < MAX_DOTS; i++) {
            ImageView dotView = new ImageView(mContext);
            dotView.setImageResource(R.drawable.page_indicator_unselected2);
            addView(dotView, lp);
        }
    
Methods Summary
public voidsetDotCount(int dotCount)

param
dotCount if less than 1 or greater than MAX_DOTS, Dots disappears

        if (dotCount > 1 && dotCount <= MAX_DOTS) {
            setVisibility(VISIBLE);
            for (int i = 0; i < MAX_DOTS; i++) {
                getChildAt(i).setVisibility(i < dotCount? VISIBLE : GONE);
            }
        } else {
            setVisibility(GONE);
        }
    
public voidsetSelected(int index)

        if (index < 0 || index >= MAX_DOTS) return;

        if (mSelected >= 0) {
            // Unselect old
            ((ImageView)getChildAt(mSelected)).setImageResource(
                    R.drawable.page_indicator_unselected2);
        }
        ((ImageView)getChildAt(index)).setImageResource(R.drawable.page_indicator);
        mSelected = index;