FileDocCategorySizeDatePackage
CandidateViewContainer.javaAPI DocAndroid 1.5 API2903Wed May 06 22:42:48 BST 2009com.android.inputmethod.latin

CandidateViewContainer

public class CandidateViewContainer extends android.widget.LinearLayout implements android.view.View.OnTouchListener

Fields Summary
private android.view.View
mButtonLeft
private android.view.View
mButtonRight
private android.view.View
mButtonLeftLayout
private android.view.View
mButtonRightLayout
private CandidateView
mCandidates
Constructors Summary
public CandidateViewContainer(android.content.Context screen, android.util.AttributeSet attrs)

        super(screen, attrs);
    
Methods Summary
public voidinitViews()

        if (mCandidates == null) {
            mButtonLeftLayout = findViewById(R.id.candidate_left_parent);
            mButtonLeft = findViewById(R.id.candidate_left);
            if (mButtonLeft != null) {
                mButtonLeft.setOnTouchListener(this);
            }
            mButtonRightLayout = findViewById(R.id.candidate_right_parent);
            mButtonRight = findViewById(R.id.candidate_right);
            if (mButtonRight != null) {
                mButtonRight.setOnTouchListener(this);
            }
            mCandidates = (CandidateView) findViewById(R.id.candidates);
        }
    
public booleanonTouch(android.view.View v, android.view.MotionEvent event)

        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            if (v == mButtonRight) {
                mCandidates.scrollNext();
            } else if (v == mButtonLeft) {
                mCandidates.scrollPrev();
            }
        }
        return false;
    
public voidrequestLayout()

        if (mCandidates != null) {
            int availableWidth = mCandidates.getWidth();
            int neededWidth = mCandidates.computeHorizontalScrollRange();
            int x = mCandidates.getScrollX();
            boolean leftVisible = x > 0;
            boolean rightVisible = x + availableWidth < neededWidth;
            if (mButtonLeftLayout != null) {
                mButtonLeftLayout.setVisibility(leftVisible ? VISIBLE : GONE);
            }
            if (mButtonRightLayout != null) {
                mButtonRightLayout.setVisibility(rightVisible ? VISIBLE : GONE);
            }
        }
        super.requestLayout();