当前位置: 首页>>代码示例>>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;未经允许,请勿转载。