當前位置: 首頁>>代碼示例>>Java>>正文


Java Checkable類代碼示例

本文整理匯總了Java中android.widget.Checkable的典型用法代碼示例。如果您正苦於以下問題:Java Checkable類的具體用法?Java Checkable怎麽用?Java Checkable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Checkable類屬於android.widget包,在下文中一共展示了Checkable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateOnScreenCheckedViews

import android.widget.Checkable; //導入依賴的package包/類
/**
 * Perform a quick, in-place update of the checked or activated state on all
 * visible item views. This should only be called when a valid choice mode
 * is active.
 */
private void updateOnScreenCheckedViews() {
	Iterator<?> it = frames.entrySet().iterator();
	View child = null;
	while (it.hasNext()) {
		Map.Entry<?, FreeFlowItem> pairs = (Map.Entry<?, FreeFlowItem>) it
				.next();
		child = pairs.getValue().view;
		boolean isChecked = isChecked(pairs.getValue().itemSection,
				pairs.getValue().itemIndex);
		if (child instanceof Checkable) {
			((Checkable) child).setChecked(isChecked);
		} else {
			child.setActivated(isChecked);
		}
	}
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:22,代碼來源:FreeFlowContainer.java

示例2: setSelectedTab

import android.widget.Checkable; //導入依賴的package包/類
protected void setSelectedTab(int position, boolean fromViewPageListener) {
    if (!fromViewPageListener) {
        mCurrentPosition = position;
        mCurrentPositionOffset = 0;
    }
    View v = getVirtualChildAt(position, true);
    if (mPreCheckView == null || mPreCheckView != v) {
        if (mAutoCheckState) {
            if (mPreCheckView instanceof Checkable) {
                ((Checkable) mPreCheckView).setChecked(false);
            }
        }
        mPreCheckView = v;
        if (v instanceof Checkable) {
            ((Checkable) v).setChecked(true);
        }
    }
    invalidate();
}
 
開發者ID:rexyren,項目名稱:PageScrollView,代碼行數:20,代碼來源:PageScrollTab.java

示例3: setCheckedAtPosition

import android.widget.Checkable; //導入依賴的package包/類
public boolean setCheckedAtPosition(int pos, boolean checked) {
    if (pos < 0) {
        pos = mCurrentPosition;
    }
    int itemCount = getTabItemCount();
    if (pos >= 0 && pos < itemCount) {
        View v = getVirtualChildAt(pos, true);
        if (v instanceof Checkable) {
            Checkable cv = (Checkable) v;
            if (cv.isChecked() != checked) {
                cv.setChecked(checked);
                return true;
            }
        }
    }
    return false;
}
 
開發者ID:rexyren,項目名稱:PageScrollView,代碼行數:18,代碼來源:PageScrollTab.java

示例4: getView

import android.widget.Checkable; //導入依賴的package包/類
@Override
public WrapperView getView(int position, View convertView, ViewGroup parent) {
	WrapperView wv = (convertView == null) ? new WrapperView(mContext) : (WrapperView) convertView;
	View item = mDelegate.getView(position, wv.mItem, parent);
	View header = null;
	if (previousPositionHasSameHeader(position)) {
		recycleHeaderIfExists(wv);
	} else {
		header = configureHeader(wv, position);
	}
	if((item instanceof Checkable) && !(wv instanceof CheckableWrapperView)) {
		// Need to create Checkable subclass of WrapperView for ListView to work correctly
		wv = new CheckableWrapperView(mContext);
	} else if(!(item instanceof Checkable) && (wv instanceof CheckableWrapperView)) {
		wv = new WrapperView(mContext);
	}
	wv.update(item, header, mDivider, mDividerHeight);
	return wv;
}
 
開發者ID:tony-Shx,項目名稱:Swface,代碼行數:20,代碼來源:AdapterWrapper.java

示例5: updateOnScreenCheckedViews

import android.widget.Checkable; //導入依賴的package包/類
private void updateOnScreenCheckedViews() {
    boolean useActivated;
    int firstPos = this.mFirstPosition;
    int count = getChildCount();
    if (VERSION.SDK_INT >= 11) {
        useActivated = true;
    } else {
        useActivated = false;
    }
    for (int i = 0; i < count; i++) {
        View child = getChildAt(i);
        int position = firstPos + i;
        if (child instanceof Checkable) {
            ((Checkable) child).setChecked(((Boolean) this.mCheckStates.get(position, Boolean.valueOf(false))).booleanValue());
        } else if (useActivated) {
            child.setActivated(((Boolean) this.mCheckStates.get(position, Boolean.valueOf(false))).booleanValue());
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:20,代碼來源:AbsHListView.java

示例6: updateOnScreenCheckedViews

import android.widget.Checkable; //導入依賴的package包/類
/**
 * Perform a quick, in-place update of the checked or activated state on all
 * visible item views. This should only be called when a valid choice mode
 * is active.
 */
private void updateOnScreenCheckedViews() {
	final int firstPos = mFirstPosition;
	final int count = getChildCount();
	final boolean useActivated = android.os.Build.VERSION.SDK_INT >= 11;
	for (int i = 0; i < count; i++) {
		final View child = getChildAt(i);
		final int position = firstPos + i;

		if (child instanceof Checkable) {
			((Checkable) child).setChecked(mCheckStates
					.get(position, false));
		} else if (useActivated) {
			child.setActivated(mCheckStates.get(position, false));
		}
	}
}
 
開發者ID:junchenChow,項目名稱:exciting-app,代碼行數:22,代碼來源:AbsHListView.java

示例7: bindView

import android.widget.Checkable; //導入依賴的package包/類
@Override
public void bindView(View view, Context context, Cursor cursor) {
    PhotoItemLayout layout = (PhotoItemLayout) view;
    PhotupImageView iv = layout.getImageView();

    final PhotoUpload upload = MediaStoreCursorHelper.photosCursorToSelection(
            MediaStoreCursorHelper.MEDIA_STORE_CONTENT_URI, cursor);

    if (null != upload) {
    	iv.requestThumbnail(upload, true);
        layout.setPhotoSelection(upload);

        if (null != mController) {
            ((Checkable) view).setChecked(mController.isSelected(upload));
        }
    }
}
 
開發者ID:xulailing,項目名稱:android-open-project-demo-master,代碼行數:18,代碼來源:UsersPhotosCursorAdapter.java

示例8: instantiateItem

import android.widget.Checkable; //導入依賴的package包/類
@Override
public Object instantiateItem(ViewGroup container, int position) {
    View view = mInflater.inflate(R.layout.sentence_detail, null);
    final Sentence sentence = mSentences.get(position);
    JSONObject content = sentence.getJsonObjectContent();
    final Checkable checkable = (Checkable) view.findViewById(R.id.content);
    checkable.setChecked(sentence.getIsStar());
    final CheckableImageView favoriteBtn = (CheckableImageView) view.findViewById(R.id.favorite);
    favoriteBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            checkable.toggle();
            if (mFavoriteClickListener != null) {
                mFavoriteClickListener.onFavoriteClick(sentence, checkable.isChecked());
            }
        }
    });
    ((TextView) view.findViewById(R.id.day)).setText(sentence.getDateline());
    ((TextView) view.findViewById(R.id.en_content)).setText("  " + sentence.getContent());
    ((TextView) view.findViewById(R.id.cn_content)).setText("  " + content.optString("note"));
    loadImg(sentence, (NetworkImageView) view.findViewById(R.id.image));
    container.addView(view);
    return view;
}
 
開發者ID:enuoCM,項目名稱:DE-MVP-Clean,代碼行數:25,代碼來源:SentenceDetailPageAdapter.java

示例9: onBindViewHolder

import android.widget.Checkable; //導入依賴的package包/類
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    final Sentence sentence = mSentences.get(position);
    holder.mCheckable.setChecked(sentence.getIsStar());
    holder.mIndicatorView.setVisibility(mFocusedSentenceId == sentence.getId() ? View.VISIBLE : View.INVISIBLE);
    holder.mContentTextView.setText(sentence.getContent());
    holder.mDayTextView.setText(sentence.getDateline());
    final Checkable checkable = holder.mCheckable;
    holder.mImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            checkable.toggle();
            if (mFavoriteClickListener != null) {
                mFavoriteClickListener.onFavoriteClick(sentence, checkable.isChecked());
            }
        }
    });
    holder.itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mOnItemClickListener != null) {
                mOnItemClickListener.onSentenceItemClicked(sentence);
            }
        }
    });
}
 
開發者ID:enuoCM,項目名稱:DE-MVP-Clean,代碼行數:27,代碼來源:SentencesAdapter.java

示例10: setChecked

import android.widget.Checkable; //導入依賴的package包/類
/**
 * Sets the checked status of a checkable.
 *
 * @param viewId  The view id.
 * @param checked The checked status;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setChecked(@IdRes int viewId, boolean checked) {
    View view = getView(viewId);
    // View unable cast to Checkable
    if (view instanceof Checkable) {
        ((Checkable) view).setChecked(checked);
    }
    return this;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:BaseViewHolder.java

示例11: isChecked

import android.widget.Checkable; //導入依賴的package包/類
@Override
public boolean isChecked() {
    View child = getChildAt(0);
    if (child instanceof Checkable)
        return ((Checkable) child).isChecked();
    else
        return false;
}
 
開發者ID:ultrasonic,項目名稱:ultrasonic,代碼行數:9,代碼來源:DragSortItemViewCheckable.java

示例12: getView

import android.widget.Checkable; //導入依賴的package包/類
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    DragSortItemView v;
    View child;
    // Log.d("mobeta",
    // "getView: position="+position+" convertView="+convertView);
    if (convertView != null) {
        v = (DragSortItemView) convertView;
        View oldChild = v.getChildAt(0);

        child = mAdapter.getView(position, oldChild, DragSortListView.this);
        if (child != oldChild) {
            // shouldn't get here if user is reusing convertViews
            // properly
            if (oldChild != null) {
                v.removeViewAt(0);
            }
            v.addView(child);
        }
    } else {
        child = mAdapter.getView(position, null, DragSortListView.this);
        if (child instanceof Checkable) {
            v = new DragSortItemViewCheckable(getContext());
        } else {
            v = new DragSortItemView(getContext());
        }
        v.setLayoutParams(new AbsListView.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        v.addView(child);
    }

    // Set the correct item height given drag state; passed
    // View needs to be measured if measurement is required.
    adjustItem(position + getHeaderViewsCount(), v, true);

    return v;
}
 
開發者ID:ultrasonic,項目名稱:ultrasonic,代碼行數:40,代碼來源:DragSortListView.java

示例13: onFinishInflate

import android.widget.Checkable; //導入依賴的package包/類
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        View v = getChildAt(i);
        if (v instanceof Checkable) {
            mCheckableSet.add((Checkable) v);
        }
    }
}
 
開發者ID:Zyj163,項目名稱:yyox,代碼行數:12,代碼來源:CheckableLinearLayout.java

示例14: setChecked

import android.widget.Checkable; //導入依賴的package包/類
@Override
public void setChecked(boolean checked) {
    if (checked == mChecked) {
        return;
    }
    mChecked = checked;
    for (Checkable checkable : mCheckableSet) {
        checkable.setChecked(checked);
    }
    refreshDrawableState();
}
 
開發者ID:Zyj163,項目名稱:yyox,代碼行數:12,代碼來源:CheckableLinearLayout.java

示例15: bindData

import android.widget.Checkable; //導入依賴的package包/類
private void bindData(ViewHolder viewHolder, int position, List<? extends Map<String, ?>> mData) {
    Map<String, ?> map = mData.get(position);
    final int count = mTo.length;
    for (int i = 0; i < count; i++) {
        Object v = viewHolder.clientView[i];
        Object data = map.get(mFrom[i]);
        String text = data == null ? "" : data.toString();
        if (text == null) {
            text = "";
        }
        if (v instanceof Checkable) {
            if (data instanceof Boolean) {
                ((Checkable) v).setChecked((Boolean) data);
            } else if (v instanceof TextView) {
                // Note: keep the instanceof TextView check at the bottom of these
                // ifs since a lot of views are TextViews (e.g. CheckBoxes).
                setViewText((TextView) v, text);
            } else {
                throw new IllegalStateException(v.getClass().getName() +
                        " should be bound to a Boolean, not a " +
                        (data == null ? "<unknown type>" : data.getClass()));
            }
        } else if (v instanceof TextView) {
            // Note: keep the instanceof TextView check at the bottom of these
            // ifs since a lot of views are TextViews (e.g. CheckBoxes).
            setViewText((TextView) v, text);
        } else if (v instanceof ImageView) {
            if (data instanceof Integer) {
                setViewImage((ImageView) v, (Integer) data);
            } else {
                setViewImage((ImageView) v, text);
            }
        } else {
            throw new IllegalStateException(v.getClass().getName() + " is not a " +
                    " view that can be bounds by this SimpleAdapter");
        }
    }
}
 
開發者ID:abook23,項目名稱:godlibrary,代碼行數:39,代碼來源:SimpleAdapter.java


注:本文中的android.widget.Checkable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。