當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。