本文整理汇总了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);
}
}
}
示例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();
}
示例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;
}
示例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;
}
示例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());
}
}
}
示例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));
}
}
}
示例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));
}
}
}
示例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;
}
示例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);
}
}
});
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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();
}
示例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");
}
}
}