当前位置: 首页>>代码示例>>Java>>正文


Java ImageView.setId方法代码示例

本文整理汇总了Java中android.widget.ImageView.setId方法的典型用法代码示例。如果您正苦于以下问题:Java ImageView.setId方法的具体用法?Java ImageView.setId怎么用?Java ImageView.setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.ImageView的用法示例。


在下文中一共展示了ImageView.setId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initDots

import android.widget.ImageView; //导入方法依赖的package包/类
public static void initDots(int pageNum,LinearLayout mLayoutDots,Activity context){
    //有几页显示几个小圆点
    for (int i = 0; i < pageNum; i++) {
        if (pageNum > 1) {
            ImageView dots = new ImageView(context);
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            params.setMargins(CommonUtil.dip2px(context,5),0,0,0);
            params.width = CommonUtil.dip2px(context,5);
            params.height = CommonUtil.dip2px(context,5);
            dots.setLayoutParams(params);
            if (i == 0) {
                //第一个默认显示选中状态
                dots.setImageResource(R.drawable.dot_selected);
            } else {
                dots.setImageResource(R.drawable.dot_normal);
            }
            dots.setId(i);
            mLayoutDots.addView(dots);
        }
    }
}
 
开发者ID:nickyangjun,项目名称:EasyEmoji,代码行数:22,代码来源:ChatPanelUtils.java

示例2: createImageView

import android.widget.ImageView; //导入方法依赖的package包/类
private ImageView createImageView(int position, final boolean isMultiImage) {
	String url = imagesList.get(position);
	ImageView imageView = new ColorFilterImageView(getContext());
	if(isMultiImage){
		imageView.setScaleType(ScaleType.CENTER_CROP);
		imageView.setLayoutParams(position % MAX_PER_ROW_COUNT == 0 ?moreParaColumnFirst : morePara);
	}else {
		imageView.setAdjustViewBounds(true);
		imageView.setScaleType(ScaleType.CENTER_CROP);
		imageView.setMaxHeight(pxOneMaxWandH);
		imageView.setLayoutParams(onePicPara);
	}

	imageView.setTag(R.string.zone_img_position,position);
	imageView.setId(url.hashCode());
	imageView.setOnClickListener(mImageViewOnClickListener);
	ImageLoaderUtils.display(getContext(), imageView, ImageUtil.getImageUrl(url));
	return imageView;
}
 
开发者ID:wp521,项目名称:MyFire,代码行数:20,代码来源:MultiImageView.java

示例3: EditTextDialogBuilder

import android.widget.ImageView; //导入方法依赖的package包/类
public EditTextDialogBuilder(Context context) {
    super(context);
    mEditText = new EditText(mContext);
    mEditText.setHintTextColor(QMUIResHelper.getAttrColor(mContext, R.attr.qmui_config_color_gray_3));
    mEditText.setTextColor(QMUIResHelper.getAttrColor(mContext, R.attr.qmui_config_color_black));
    mEditText.setTextSize(TypedValue.COMPLEX_UNIT_PX, QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_content_message_text_size));
    mEditText.setFocusable(true);
    mEditText.setFocusableInTouchMode(true);
    mEditText.setImeOptions(EditorInfo.IME_ACTION_GO);
    mEditText.setGravity(Gravity.CENTER_VERTICAL);
    mEditText.setId(R.id.qmui_dialog_edit_input);

    mRightImageView = new ImageView(mContext);
    mRightImageView.setId(R.id.qmui_dialog_edit_right_icon);
    mRightImageView.setVisibility(View.GONE);
}
 
开发者ID:coopese,项目名称:qmui,代码行数:17,代码来源:QMUIDialog.java

示例4: MarkItemView

import android.widget.ImageView; //导入方法依赖的package包/类
public MarkItemView(Context context) {
	super(context);
	mContext = context;
	mCheckedView = new ImageView(mContext);
	mCheckedView.setImageResource(R.drawable.qmui_s_dialog_check_mark);
	mCheckedView.setId(QMUIViewHelper.generateViewId());
	LayoutParams checkLp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	checkLp.addRule(CENTER_VERTICAL, TRUE);
	checkLp.addRule(ALIGN_PARENT_RIGHT, TRUE);
	checkLp.leftMargin = QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_menu_item_check_icon_margin_horizontal);
	addView(mCheckedView,checkLp);

	mTextView = createItemTextView(mContext);
	LayoutParams tvLp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	tvLp.addRule(ALIGN_PARENT_LEFT, TRUE);
	tvLp.addRule(LEFT_OF, mCheckedView.getId());
	addView(mTextView,tvLp);
}
 
开发者ID:coopese,项目名称:qmui,代码行数:19,代码来源:QMUIDialogMenuItemView.java

示例5: MyViewHolder

import android.widget.ImageView; //导入方法依赖的package包/类
MyViewHolder(View view, PhotoLoaderInterface imageLoaderInterface, PhotoShowPicListener picOnClickListener) {
    super(view);
    this.picOnClickListener = picOnClickListener;
    iv_pic = imageLoaderInterface.createImageView(view.getContext());
    FrameLayout.LayoutParams pic_params = new FrameLayout.LayoutParams(icHeight, icHeight);
    pic_params.setMargins(10, 10, 10, 10);
    iv_pic.setLayoutParams(pic_params);
    iv_del = new ImageView(view.getContext());
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.TOP | Gravity.END;
    iv_del.setPadding(5, 5, 5, 5);
    iv_del.setLayoutParams(layoutParams);
    iv_pic.setId(R.id.iv_image_show_picker_pic);
    iv_del.setId(R.id.iv_image_show_picker_del);
    iv_pic.setOnClickListener(this);
    iv_del.setOnClickListener(this);
}
 
开发者ID:yangchong211,项目名称:YCPhoto,代码行数:18,代码来源:PhotoShowAdapter.java

示例6: setIndicator

import android.widget.ImageView; //导入方法依赖的package包/类
/**
 * 设置页码
 */
private static void setIndicator(ViewGroup indicator, int total, int current) {
    if (total <= 1) {
        indicator.removeAllViews();
    } else {
        indicator.removeAllViews();
        for (int i = 0; i < total; i++) {
            ImageView imgCur = new ImageView(indicator.getContext());
            imgCur.setId(i);
            // 判断当前页码来更新
            if (i == current) {
                imgCur.setBackgroundResource(R.drawable.nim_moon_page_selected);
            } else {
                imgCur.setBackgroundResource(R.drawable.nim_moon_page_unselected);
            }

            indicator.addView(imgCur);
        }
    }
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:23,代码来源:ActionsPanel.java

示例7: getAccessoryView

import android.widget.ImageView; //导入方法依赖的package包/类
private static ImageView getAccessoryView(ATableViewCell cell, ATableViewCellAccessoryType accessoryType) {
    LinearLayout containerView = (LinearLayout) cell.findViewById(R.id.containerView);

    // check if accessoryView already exists for current cell before creating a new instance.
    ImageView accessoryView = (ImageView) containerView.findViewById(R.id.accessoryView);
    if (accessoryView == null) {
        Resources res = cell.getResources();

        // get marginRight for accessoryView, DisclosureButton has a different one.
        LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
        int marginRight = (int) res.getDimension(R.dimen.atv_cell_content_margin);
        if (accessoryType == ATableViewCellAccessoryType.DisclosureButton) {
            marginRight = (int) res.getDimension(R.dimen.atv_cell_disclosure_button_margin_right);
        }
        params.setMargins(0, 0, marginRight, 0);

        // setup.
        accessoryView = new ATableViewCellAccessoryView(cell.getContext());
        accessoryView.setId(R.id.accessoryView);
        accessoryView.setLayoutParams(params);

        containerView.addView(accessoryView);
    }

    return accessoryView;
}
 
开发者ID:hh-in-zhuzhou,项目名称:ShangHanLun,代码行数:27,代码来源:ATableViewCellAccessoryView.java

示例8: initExpandIcon

import android.widget.ImageView; //导入方法依赖的package包/类
private void initExpandIcon(RelativeLayout headerLayout) {
    expandIcon = new ImageView(getContext());

    int margin = (int) getContext().getResources().getDimension(R.dimen.icon_margin);

    RelativeLayout.LayoutParams expandIconParams = new RelativeLayout.LayoutParams((int) getResources().getDimension(R.dimen.expand_drawable_size), (int) getResources().getDimension(R.dimen.expand_drawable_size));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        expandIconParams.addRule(RelativeLayout.ALIGN_PARENT_END);
    } else {
        expandIconParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    }
    expandIconParams.addRule(RelativeLayout.CENTER_VERTICAL);
    expandIconParams.setMargins(margin, margin, margin, margin);

    expandIcon.setId(ExpandableUtils.ID_EXPAND_ICON);
    expandIcon.setLayoutParams(expandIconParams);
    expandIcon.setImageDrawable(expandIndicator == null ? ContextCompat.getDrawable(getContext(), R.drawable.ic_down) : expandIndicator);

    headerLayout.addView(expandIcon);
}
 
开发者ID:robertlevonyan,项目名称:materialExpansionPanel,代码行数:22,代码来源:Expandable.java

示例9: MarkItemView

import android.widget.ImageView; //导入方法依赖的package包/类
public MarkItemView(Context context) {
    super(context);
    mContext = context;
    mCheckedView = new ImageView(mContext);
    mCheckedView.setImageResource(R.drawable.qmui_s_dialog_check_mark);
    mCheckedView.setId(QMUIViewHelper.generateViewId());
    LayoutParams checkLp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    checkLp.addRule(CENTER_VERTICAL, TRUE);
    checkLp.addRule(ALIGN_PARENT_RIGHT, TRUE);
    checkLp.leftMargin = QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_menu_item_check_icon_margin_horizontal);
    addView(mCheckedView, checkLp);

    mTextView = createItemTextView(mContext);
    LayoutParams tvLp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    tvLp.addRule(ALIGN_PARENT_LEFT, TRUE);
    tvLp.addRule(LEFT_OF, mCheckedView.getId());
    addView(mTextView, tvLp);
}
 
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:19,代码来源:QMUIDialogMenuItemView.java

示例10: initPhysicsLayout

import android.widget.ImageView; //导入方法依赖的package包/类
private void initPhysicsLayout() {
    for (int i=0; i<10; i++) {
        ImageView imageView = new ImageView(StickerCollectionActivity.this);
        imageView.setImageResource(R.drawable.mobike_logo);
        LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(
                getResources().getDimensionPixelSize(R.dimen.square_size),
                getResources().getDimensionPixelSize(R.dimen.square_size));
        imageView.setLayoutParams(llp);
        imageView.setId(catIndex);
        catIndex++;
        mPhysicsLayout.addView(imageView);
        Glide.with(StickerCollectionActivity.this)
                .load(R.drawable.mobike_logo)
                .placeholder(R.drawable.mobike_logo)
                .into(imageView);
    }


}
 
开发者ID:yiwent,项目名称:Mobike,代码行数:20,代码来源:StickerCollectionActivity.java

示例11: CheckItemView

import android.widget.ImageView; //导入方法依赖的package包/类
public CheckItemView(Context context, boolean right) {
	super(context);
	mContext = context;
	mCheckedView = new ImageView(mContext);
	mCheckedView.setImageDrawable(QMUIResHelper.getAttrDrawable(context, R.attr.qmui_s_checkbox));
	mCheckedView.setId(QMUIViewHelper.generateViewId());
	LayoutParams checkLp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	checkLp.addRule(CENTER_VERTICAL, TRUE);
	if(right){
		checkLp.addRule(ALIGN_PARENT_RIGHT, TRUE);
		checkLp.leftMargin = QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_menu_item_check_icon_margin_horizontal);
	}else{
		checkLp.addRule(ALIGN_PARENT_LEFT, TRUE);
		checkLp.rightMargin =QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_menu_item_check_icon_margin_horizontal);
	}

	addView(mCheckedView,checkLp);

	mTextView = createItemTextView(mContext);
	LayoutParams tvLp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	if(right){
		tvLp.addRule(LEFT_OF, mCheckedView.getId());
	}else{
		tvLp.addRule(RIGHT_OF, mCheckedView.getId());
	}

	addView(mTextView,tvLp);
}
 
开发者ID:coopese,项目名称:qmui,代码行数:29,代码来源:QMUIDialogMenuItemView.java

示例12: initItem

import android.widget.ImageView; //导入方法依赖的package包/类
/**
 * 设置ImageView 的宽高等属性
 */
private void initItem() {
    mItemWidth = (mWidth - mPadding * 2 - mMargin * (mColumn - 1)) / mColumn;
    mItems = new ImageView[mColumn * mColumn];
    //生成Item,设置Rule
    for (int i = 0; i < mItems.length; i++) {
        ImageView item = new ImageView(getContext());
        item.setOnClickListener(this);
        item.setImageBitmap(mItemBitmaps.get(i).getBitmap());
        mItems[i] = item;
        item.setId(i+1);
        // 在item的tag中存储了index
        item.setTag(i + "_" + mItemBitmaps.get(i).getIndex());

        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(mItemWidth, mItemWidth);
        //设置item间横向间隙,通过rightMargin
        //不是最后一列
        if ((i + 1) % mColumn != 0){
            lp.rightMargin = mMargin;
        }
        // 不是第一列
        if (i % mColumn != 0){
            lp.addRule(RelativeLayout.RIGHT_OF, mItems[i -1].getId());
        }
        // 不是第一行,设置topMargin和rule
        if ((i + 1) > mColumn) {
            lp.topMargin = mMargin;
            lp.addRule(RelativeLayout.BELOW, mItems[i - mColumn].getId());
        }
        addView(item, lp);
    }
}
 
开发者ID:charsdavy,项目名称:Puzzle,代码行数:35,代码来源:PuzzleLayout.java

示例13: onActivityResult

import android.widget.ImageView; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	// TODO Auto-generated method stub
	super.onActivityResult(requestCode, resultCode, data);
	paoPaoQuan.setSelection(paoPaoState);
	// requestCode标示请求的标示 resultCode表示有数据
	Log.d("js", requestCode + "//" + resultCode + "**" + data);
	if (requestCode==4||data != null) {
		int childCount = imageGrid.getChildCount();
		if (childCount > 9) {
			Toast.makeText(this, "最多选择9张图片", 1).show();
		} else {
			imageId++;
			String fPath = null;
			if (requestCode == 4) {
				fPath = mCurrentPhotoPath;
			}else{
				Uri uri = data.getData(); // 得到Uri
				if((uri!=null&&!uri.equals(""))){
					fPath = StaticMethod.getImageAbsolutePath(this, uri); // 转化为路径
				}
			}
			Bitmap b = BitmapFactory.decodeFile(fPath);
			b = StaticMethod.getThumImg(b, 100);
			ImageView image = new ImageView(this);
			image.setLayoutParams(new LayoutParams(130, 130));
			image.setScaleType(ScaleType.FIT_XY);
			image.setId(imageId);
			image.setTag(fPath);
			image.setImageBitmap(b);
			image.setOnClickListener(this);
			imageGrid.addView(image, childCount - 1);
			}
	}

}
 
开发者ID:smartbeng,项目名称:PaoMovie,代码行数:37,代码来源:SendPaoPaoPic.java

示例14: CheckItemView

import android.widget.ImageView; //导入方法依赖的package包/类
public CheckItemView(Context context, boolean right) {
    super(context);
    mContext = context;
    mCheckedView = new ImageView(mContext);
    mCheckedView.setImageDrawable(QMUIResHelper.getAttrDrawable(context, R.attr.qmui_s_checkbox));
    mCheckedView.setId(QMUIViewHelper.generateViewId());
    LayoutParams checkLp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    checkLp.addRule(CENTER_VERTICAL, TRUE);
    if (right) {
        checkLp.addRule(ALIGN_PARENT_RIGHT, TRUE);
        checkLp.leftMargin = QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_menu_item_check_icon_margin_horizontal);
    } else {
        checkLp.addRule(ALIGN_PARENT_LEFT, TRUE);
        checkLp.rightMargin = QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_menu_item_check_icon_margin_horizontal);
    }

    addView(mCheckedView, checkLp);

    mTextView = createItemTextView(mContext);
    LayoutParams tvLp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    if (right) {
        tvLp.addRule(LEFT_OF, mCheckedView.getId());
    } else {
        tvLp.addRule(RIGHT_OF, mCheckedView.getId());
    }

    addView(mTextView, tvLp);
}
 
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:29,代码来源:QMUIDialogMenuItemView.java

示例15: createImageView

import android.widget.ImageView; //导入方法依赖的package包/类
private ImageView createImageView(String thumbUrl,int position,LayoutParams params){

        ImageView imageView = new ImageView(getContext());
        imageView.setId(thumbUrl.hashCode());//指定id

        imageView.setLayoutParams(params);
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
//                    imageView.setImageResource(thumbUrl);



        imageView.setTag(position);
        imageView.setOnClickListener(ImageViewOnClickListener);

        return  imageView;

    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:MultiImageView.java


注:本文中的android.widget.ImageView.setId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。