Code example for View

Methods: getImportantForAccessibility, setImportantForAccessibility, setVisibility

0
    @SuppressLint("NewApi") 
    public void setEmptyView(View emptyView) {
        mEmptyView = emptyView;
        if (VERSION.SDK_INT >= 16
                && emptyView != null
                && emptyView.getImportantForAccessibility() == View.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
            emptyView
                    .setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
        } 
        final T adapter = getAdapter();
        final boolean empty = adapter == null || adapter.isEmpty();
        updateEmptyStatus(empty);
    } 
 
    @Override 
    public void setFocusable(boolean focusable) {
        final T adapter = getAdapter();
        final boolean empty = adapter == null || adapter.getCount() == 0;
        mDesiredFocusableState = focusable;
        if (!focusable) {
            mDesiredFocusableInTouchModeState = false;
        } 
        super.setFocusable(focusable && (!empty || isInFilterMode()));
    } 
 
    @Override 
    public void setFocusableInTouchMode(boolean focusable) {
        final T adapter = getAdapter();
        final boolean empty = adapter == null || adapter.getCount() == 0;
 
        mDesiredFocusableInTouchModeState = focusable;
        if (focusable) {
            mDesiredFocusableState = true;
        } 
 
        super.setFocusableInTouchMode(focusable && (!empty || isInFilterMode()));
    } 
 
    void setNextSelectedPositionInt(int position) {
        mNextSelectedPosition = position;
        mNextSelectedRowId = getItemIdAtPosition(position);
        if (mNeedSync && mSyncMode == AdapterView.SYNC_SELECTED_POSITION
                && position >= 0) {
            mSyncPosition = position;
            mSyncRowId = mNextSelectedRowId;
        } 
    } 
 
    @Override 
    public void setOnClickListener(OnClickListener l) {
        throw new RuntimeException(
                "Don't call setOnClickListener for an AdapterView. " 
                        + "You probably want setOnItemClickListener instead"); 
    } 
 
    public void setOnItemClickListener(OnItemClickListener listener) {
        mOnItemClickListener = listener;
    } 
 
    public void setOnItemLongClickListener(OnItemLongClickListener listener) {
        if (!isLongClickable()) { 
            setLongClickable(true); 
        } 
        mOnItemLongClickListener = listener;
    } 
 
    public void setOnItemSelectedListener(OnItemSelectedListener listener) {
        mOnItemSelectedListener = listener;
    } 
 
    void setSelectedPositionInt(int position) {
        mSelectedPosition = position;
        mSelectedRowId = getItemIdAtPosition(position);
    } 
 
    public abstract void setSelection(int position);
 
    private void updateEmptyStatus(boolean empty) {
        if (isInFilterMode()) { 
            empty = false;
        } 
        if (empty) {
            if (mEmptyView != null) {
                mEmptyView.setVisibility(View.VISIBLE);
                setVisibility(View.GONE);
            } else { 
                setVisibility(View.VISIBLE);
            } 
            if (mDataChanged) {
                this.onLayout(false, getLeft(), getTop(), getRight(),
                        getBottom()); 
            } 
        } else { 
            if (mEmptyView != null) {
                mEmptyView.setVisibility(View.GONE);
            } 
            setVisibility(View.VISIBLE);
        } 
    } 
}