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


Java ImageView.setImageBitmap方法代码示例

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


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

示例1: instantiateItem

import android.widget.ImageView; //导入方法依赖的package包/类
@Override
public Object instantiateItem(ViewGroup container, final int position) {
    View itemView = LayoutInflater.from(mContext).inflate(R.layout.main_pager_item, container, false);

    ImageView imageView = (ImageView) itemView.findViewById(R.id.pager_item_image_view);
    imageView.setImageBitmap(mResources[position]);

    if(position < recommend_bitmaps.size() &&
            position != 0)
    {
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getApplicationContext(), ActivityShowVisuallySimilarImagesSelect.class);
                intent.putExtra("url", urls.get(position-1));
                intent.putExtra("uri", uris.get(position-1));
                startActivityForResult(intent, SELECT_REQUEST);
            }
        });
    }

    container.addView(itemView);
    return itemView;
}
 
开发者ID:jmpaaak,项目名称:EyeShopping,代码行数:25,代码来源:MainActivity.java

示例2: getImageListener

import android.widget.ImageView; //导入方法依赖的package包/类
/**
 * The default implementation of ImageListener which handles basic functionality
 * of showing a default image until the network response is received, at which point
 * it will switch to either the actual image or the error image.
 * @param view The imageView that the listener is associated with.
 * @param defaultImageResId Default image resource ID to use, or 0 if it doesn't exist.
 * @param errorImageResId Error image resource ID to use, or 0 if it doesn't exist.
 */
public static ImageListener getImageListener(final ImageView view,
        final int defaultImageResId, final int errorImageResId) {
    return new ImageListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            if (errorImageResId != 0) {
                view.setImageResource(errorImageResId);
            }
        }

        @Override
        public void onResponse(ImageContainer response, boolean isImmediate) {
            if (response.getBitmap() != null) {
                view.setImageBitmap(response.getBitmap());
            } else if (defaultImageResId != 0) {
                view.setImageResource(defaultImageResId);
            }
        }
    };
}
 
开发者ID:wangzhaosheng,项目名称:publicProject,代码行数:29,代码来源:ImageLoader.java

示例3: addScaledImageView

import android.widget.ImageView; //导入方法依赖的package包/类
private void addScaledImageView(Bitmap original, int sampleSize, LinearLayout container) {

        // inSampleSize tells the loader how much to scale the final image, which it does at
        // load time by simply reading less pixels for every pixel value in the final bitmap.
        // Note that it only scales by powers of two, so a value of two results in a bitmap
        // 1/2 the size of the original and a value of four results in a bitmap 1/4 the original
        // size. Intermediate values are rounded down, so a value of three results in a bitmap 1/2
        // the original size.

        BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();
        bitmapOptions.inSampleSize = sampleSize;

        Bitmap scaledBitmap = BitmapFactory.decodeResource(getResources(),
                R.drawable.jellybean_statue, bitmapOptions);
        ImageView scaledImageView = new ImageView(this);
        scaledImageView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT));
        scaledImageView.setImageBitmap(scaledBitmap);
        container.addView(scaledImageView);
    }
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:21,代码来源:BitmapScaling.java

示例4: onPostExecute

import android.widget.ImageView; //导入方法依赖的package包/类
/**
 * Once the image is downloaded, associates it to the imageView
 */
@Override
protected void onPostExecute(Bitmap bitmap) {
    if (isCancelled()) {
        bitmap = null;
    }
    addBitmapToCache(position, bitmap);
    if (imageViewReference != null) {
        ImageView imageView = imageViewReference.get();
        BitmapFetcherTask bitmapDownloaderTask = getBitmapDownloaderTask(imageView);
        if (this == bitmapDownloaderTask) {
            imageView.setImageBitmap(bitmap);
            Animation anim = AnimationUtils.loadAnimation(imageView.getContext(), android.R.anim.fade_in);
            imageView.setAnimation(anim);
            anim.start();
        }
    } else {
        setInvisible();
    }
}
 
开发者ID:abelabbesnabi,项目名称:cordova-plugin-image-picker,代码行数:23,代码来源:ImageFetcher.java

示例5: loadViews

import android.widget.ImageView; //导入方法依赖的package包/类
public void loadViews() {
	titles = new String[mMapBitmaps.size()];
	mPics = new ArrayList<ImageView>();
	mDots = new ArrayList<View>();
	int i=0;
	for(String key:mMapBitmaps.keySet()){
		titles[i++] = key;
		ImageView iv1 = new ImageView(StationDetailAty.this);
		iv1.setImageBitmap(mMapBitmaps.get(key));
		iv1.setScaleType(ScaleType.CENTER_CROP);
		iv1.setOnClickListener(new MyOnClickListener(i));
		mPics.add(iv1);
		
		ImageView iv2 = new ImageView(StationDetailAty.this);
		iv2.setBackgroundResource(R.drawable.dot_normal);
		mDots.add(iv2);
	}
	tvTitle.setText(titles[0]);
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:20,代码来源:StationDetailAty.java

示例6: instantiateItem

import android.widget.ImageView; //导入方法依赖的package包/类
public Object instantiateItem(ViewGroup container, int position){
    View v = inflater.inflate(R.layout.viewpager_image,null);
    ImageView imgView = (ImageView) v.findViewById(R.id.viewPagerImage);
    //이미지를 가져옴
    Uri uri = Uri.fromFile(new File(cards.get(position)));

    try {
        Bitmap bitmap = MediaStore.Images.Media.getBitmap(inflater.getContext().getContentResolver(),uri);
        int nh = (int) (bitmap.getHeight() * (1024.0 / bitmap.getWidth()));
        Bitmap scaled = Bitmap.createScaledBitmap(bitmap, 1024, nh, true);

        imgView.setImageBitmap(scaled);

    } catch (IOException e) {
        e.printStackTrace();
    }
    container.addView(v);

    return v;
}
 
开发者ID:gugusny5758,项目名称:OSS-purple-06,代码行数:21,代码来源:CardNewsPagerAdapter.java

示例7: testSetImageBitmap

import android.widget.ImageView; //导入方法依赖的package包/类
@Test
public void testSetImageBitmap(){
  ImageView imageView = mWXImage.initComponentHostView(Robolectric.setupActivity(TestActivity.class));
  imageView.setLayoutParams(new ViewGroup.LayoutParams(
      ViewGroup.LayoutParams.WRAP_CONTENT,
      ViewGroup.LayoutParams.WRAP_CONTENT));
  imageView.setImageBitmap(null);
  assertNull(imageView.getDrawable());

  imageView.setImageBitmap(Bitmap.createBitmap(100, 100, Bitmap.Config.RGB_565));
  assertNotNull(imageView.getDrawable());
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:13,代码来源:WXImageTest.java

示例8: loadThumbnail

import android.widget.ImageView; //导入方法依赖的package包/类
/**
 * Load thumbnails for a directory list item.
 * @param uri The URI for the file being represented.
 * @param mimeType The mime type of the file being represented.
 * @param docFlags Flags for the file being represented.
 * @param iconThumb The itemview's thumbnail icon.
 * @param iconMimeBackground
 * @return
 */
public void loadThumbnail(Uri uri, String path, String mimeType, int docFlags, int docIcon,
                          ImageView iconMime, ImageView iconThumb, View iconMimeBackground) {
    boolean cacheHit = false;

    final String docAuthority = uri.getAuthority();
    String docId = DocumentsContract.getDocumentId(uri);
    final boolean supportsThumbnail = (docFlags & Document.FLAG_SUPPORTS_THUMBNAIL) != 0;
    final boolean allowThumbnail = MimePredicate.mimeMatches(MimePredicate.VISUAL_MIMES, mimeType);
    final boolean showThumbnail = supportsThumbnail && allowThumbnail && mThumbnailsEnabled;
    if (showThumbnail) {
        final Bitmap cachedResult = mCache.get(uri);
        if (cachedResult != null) {
            iconThumb.setImageBitmap(cachedResult);
            cacheHit = true;
            iconMimeBackground.setVisibility(View.GONE);
        } else {
            iconThumb.setImageDrawable(null);
            final LoaderTask task = new LoaderTask(uri, path, mimeType, mThumbSize, iconThumb,
                    iconMime, iconMimeBackground);
            iconThumb.setTag(task);
            ProviderExecutor.forAuthority(docAuthority).execute(task);
        }
    }

    if (cacheHit) {
        iconMime.setImageDrawable(null);
        iconMime.setAlpha(0f);
        iconThumb.setAlpha(1f);
    } else {
        // Add a mime icon if the thumbnail is being loaded in the background.
        iconThumb.setImageDrawable(null);
        iconMime.setImageDrawable(getDocumentIcon(mContext, docAuthority, docId, mimeType, docIcon));
        iconMime.setAlpha(1f);
        iconThumb.setAlpha(0f);
    }
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:46,代码来源:IconHelper.java

示例9: showThumb

import android.widget.ImageView; //导入方法依赖的package包/类
public void showThumb(String path, ImageView imgview, int width, int height) {

        if (getVideoThumbToCache(path) == null) {
            // 异步加载
            imgview.setTag(path);
            new MyBobAsynctack(imgview, path, width, height).execute(path);
        } else {
            imgview.setImageBitmap(getVideoThumbToCache(path));
        }

    }
 
开发者ID:lo625090140,项目名称:lqrwechatrongcloud,代码行数:12,代码来源:VideoThumbLoader.java

示例10: handleMessage

import android.widget.ImageView; //导入方法依赖的package包/类
@Override
public void handleMessage(Message msg) {
    super.handleMessage(msg);
    LoaderResult result = (LoaderResult) msg.obj;
    ImageView imageView = result.imageView;
    imageView.setImageBitmap(result.bitmap);
    String uri = (String) imageView.getTag(TAG_KEY_URL);
    if (uri.equals(result.uri)) {
        imageView.setImageBitmap(result.bitmap);
    }
}
 
开发者ID:wuhighway,项目名称:DailyStudy,代码行数:12,代码来源:ImageLoader.java

示例11: into

import android.widget.ImageView; //导入方法依赖的package包/类
public void into(ImageView imageView) {
        if (imageView == null) {
            return;
        }
        if (bitmap != null) {
            imageView.setImageBitmap(bitmap);
        } else {
//            imageView.setErrorHolder();
        }
    }
 
开发者ID:shenhuanet,项目名称:Sendroid,代码行数:11,代码来源:ImageRequest.java

示例12: getView

import android.widget.ImageView; //导入方法依赖的package包/类
private LinearLayout getView(int position, OnClickListener ocL, Context context) {
	Bitmap logo;
	String label;
	OnClickListener listener;
	if (beans[position] instanceof Platform) {
		logo = getIcon((Platform) beans[position]);
		label = getName((Platform) beans[position]);
		listener = ocL;
	} else {
		logo = ((CustomerLogo) beans[position]).enableLogo;
		label = ((CustomerLogo) beans[position]).label;
		listener = ocL;
	}

	LinearLayout ll = new LinearLayout(context);
	ll.setOrientation(LinearLayout.VERTICAL);

	ImageView iv = new ImageView(context);
	int dp_5 = com.mob.tools.utils.R.dipToPx(context, 5);
	iv.setPadding(dp_5, dp_5, dp_5, dp_5);
	iv.setScaleType(ScaleType.CENTER_INSIDE);
	LayoutParams lpIv = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpIv.setMargins(dp_5, dp_5, dp_5, dp_5);
	lpIv.gravity = Gravity.CENTER_HORIZONTAL;
	iv.setLayoutParams(lpIv);
	iv.setImageBitmap(logo);
	ll.addView(iv);

	TextView tv = new TextView(context);
	tv.setTextColor(0xff000000);
	tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
	tv.setSingleLine();
	tv.setIncludeFontPadding(false);
	LayoutParams lpTv = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpTv.gravity = Gravity.CENTER_HORIZONTAL;
	lpTv.weight = 1;
	lpTv.setMargins(dp_5, 0, dp_5, dp_5);
	tv.setLayoutParams(lpTv);
	tv.setText(label);
	ll.addView(tv);
	ll.setOnClickListener(listener);

	return ll;
}
 
开发者ID:liupengandroid,项目名称:ywApplication,代码行数:47,代码来源:PlatformGridView.java

示例13: afterPlatformListGot

import android.widget.ImageView; //导入方法依赖的package包/类
/** 显示平台列表 */
public void afterPlatformListGot() {
	String name = String.valueOf(reqData.get("platform"));
	int size = platformList == null ? 0 : platformList.length;
	views = new View[size];

	final int dp_24 = dipToPx(getContext(), 24);
	LinearLayout.LayoutParams lpItem = new LinearLayout.LayoutParams(dp_24, dp_24);
	final int dp_9 = dipToPx(getContext(), 9);
	lpItem.setMargins(0, 0, dp_9, 0);
	FrameLayout.LayoutParams lpMask = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	lpMask.gravity = Gravity.LEFT | Gravity.TOP;
	int selection = 0;
	for (int i = 0; i < size; i++) {
		FrameLayout fl = new FrameLayout(getContext());
		fl.setLayoutParams(lpItem);
		if (i >= size - 1) {
			fl.setLayoutParams(new LinearLayout.LayoutParams(dp_24, dp_24));
		}
		llPlat.addView(fl);
		fl.setOnClickListener(this);

		ImageView iv = new ImageView(getContext());
		iv.setScaleType(ScaleType.CENTER_INSIDE);
		iv.setImageBitmap(getPlatLogo(platformList[i]));
		iv.setLayoutParams(new FrameLayout.LayoutParams(
				LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
		fl.addView(iv);

		views[i] = new View(getContext());
		views[i].setBackgroundColor(0xcfffffff);
		views[i].setOnClickListener(this);
		if (name != null && name.equals(platformList[i].getName())) {
			views[i].setVisibility(View.INVISIBLE);
			selection = i;

			// 编辑分享内容的统计
			ShareSDK.logDemoEvent(3, platformList[i]);
		}
		views[i].setLayoutParams(lpMask);
		fl.addView(views[i]);
	}

	final int postSel = selection;
	UIHandler.sendEmptyMessageDelayed(0, 333, new Callback() {
		public boolean handleMessage(Message msg) {
			HorizontalScrollView hsv = (HorizontalScrollView)llPlat.getParent();
			hsv.scrollTo(postSel * (dp_24 + dp_9), 0);
			return false;
		}
	});
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:54,代码来源:EditPage.java

示例14: selectTo

import android.widget.ImageView; //导入方法依赖的package包/类
public void selectTo(int startPosition, int targetPostion){
    ImageView startView = dotViews.get(startPosition);
    ImageView targetView = dotViews.get(targetPostion);
    startView.setImageBitmap(unselectedBitmap);
    targetView.setImageBitmap(selectedBitmap);
}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:7,代码来源:EaseEmojiconIndicatorView.java

示例15: onCreate

import android.widget.ImageView; //导入方法依赖的package包/类
/**
 * Saving instant state for every action
 * @param savedInstanceState
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_habit_events);

    Bundle extras = getIntent().getExtras();
    if (extras!=null){
        if (extras.containsKey(HabitHistoryActivity.EXTRA_EVENT_SERIAL)){
            event = (HabitEvent) extras.getSerializable(HabitHistoryActivity.EXTRA_EVENT_SERIAL);
            position = (int) extras.getSerializable(HabitHistoryActivity.EXTRA_EVENT_POSITION);
        }
    }
    if (event==null){
        finish();
        return;
    }

    mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);


    comment = (TextView) findViewById(R.id.eventComment);
    comment.setText(event.getComment());
    image = (ImageView) findViewById(R.id.eventPhoto);
    eventdate = (TextView) findViewById(R.id.eventDate);
    eventdate.setText(dateFormat.format(event.getDate()));
    toolbar = (Toolbar) findViewById(R.id.actionbar);
    toolbar.setTitle("Habit Event");
    toolbar.setNavigationIcon(R.drawable.ic_close_button);
    setSupportActionBar(toolbar);

    if (event.getEncodedPhoto()!=null){
        imageDisplay = ImageController.base64ToImage(event.getEncodedPhoto());
        image.setImageBitmap(imageDisplay);
    }else{
        imageDisplay = null;
    }

    image.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dispatchTakePictureIntent();
        }
    });
}
 
开发者ID:CMPUT301F17T09,项目名称:GoalsAndHabits,代码行数:49,代码来源:ViewEventActivity.java


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