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


Java ImageView.setImageURI方法代码示例

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


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

示例1: onCreate

import android.widget.ImageView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_download_view);
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
        File root = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
        File imageFile = new File(root, Uri.parse(DownloadJobService.downloadLink).getLastPathSegment());
        if (imageFile.exists()) {
            ImageView imageview = (ImageView) findViewById(R.id.imagemDownload);
            imageview.setImageURI(Uri.parse("file://" + imageFile.getAbsolutePath()));
        }
        else {
            Toast.makeText(this, "Arquivo nao existe", Toast.LENGTH_SHORT).show();
        }
    }
    else {
        Toast.makeText(this, "Armazenamento externo nao esta montado...", Toast.LENGTH_SHORT).show();
    }
}
 
开发者ID:if710,项目名称:2017.2-codigo,代码行数:20,代码来源:DownloadViewActivity.java

示例2: bindEventAndShow

import android.widget.ImageView; //导入方法依赖的package包/类
protected void bindEventAndShow(final View v, ImageView targetImageView) {
    View progressBar = v.findViewById(com.daimajia.slider.library.R.id.loading_bar);
    if (progressBar != null) {
        progressBar.setVisibility(View.GONE);
    }
    Log.d("targetImageView",getUrl());

    targetImageView.setImageURI(Uri.parse(getUrl()));
    targetImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            action.onSliderClick();
        }
    });


}
 
开发者ID:Elbehiry,项目名称:Viajes,代码行数:18,代码来源:FrescoSliderView.java

示例3: onCreate

import android.widget.ImageView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mText = (TextView) findViewById(R.id.text);
    mImage = (ImageView) findViewById(R.id.image);

    mShotWatch = new ShotWatch(getContentResolver(), new ShotWatch.Listener() {
        @Override
        public void onScreenShotTaken(ScreenshotData screenshotData) {
            mText.setText(screenshotData.getFileName());
            Uri uri = Uri.parse(screenshotData.getPath());
            mImage.setImageURI(uri);
        }
    });
}
 
开发者ID:abangfadli,项目名称:shotwatch,代码行数:17,代码来源:MainActivity.java

示例4: onCreate

import android.widget.ImageView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_download_view);
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
        File root = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
        File imageFile = new File(root, Uri.parse(DownloadActivity.downloadLink).getLastPathSegment());
        if (imageFile.exists()) {
            ImageView imageview = (ImageView) findViewById(R.id.imagemDownload);
            imageview.setImageURI(Uri.parse("file://" + imageFile.getAbsolutePath()));
        }
        else {
            Toast.makeText(this, "Arquivo nao existe", Toast.LENGTH_SHORT).show();
        }
    }
    else {
        Toast.makeText(this, "Armazenamento externo nao esta montado...", Toast.LENGTH_SHORT).show();
    }
}
 
开发者ID:if710,项目名称:2017.2-codigo,代码行数:20,代码来源:DownloadViewActivity.java

示例5: showImg

import android.widget.ImageView; //导入方法依赖的package包/类
void showImg(){
    String strs[]=new String[]{"/sdcard/1.png","/sdcard/2.png"};

    int x=200,y=0,w=20,h=20;
    for(int i=0;i<strs.length;i++) {
        ImageView img = new ImageView(cxt);
        img.setImageURI(Uri.fromFile(new File(strs[i])));
        img.setTag(IMGTAGS[i]);
        initEvents(img);
        WindowManager.LayoutParams p = createLayoutParams(x*i+50, y, w, h);
        map.put(img, p);
        windowManager.addView(img, p);
    }
}
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:15,代码来源:FloatView.java

示例6: displayImage

import android.widget.ImageView; //导入方法依赖的package包/类
@Override
public void displayImage(Context context, Object path, ImageView imageView) {
    //用fresco加载图片
    Uri uri = Uri.parse((String) path);
    imageView.setImageURI(uri);

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

示例7: load

import android.widget.ImageView; //导入方法依赖的package包/类
/**
 * Load the image indicated by the fileName into destination ImageView.
 * @param destination imageView to be set
 * @param fileName fileName of the image to be set. If null, no image is set.
 */
public static void load(ImageView destination, String fileName) {
    if (fileName != null) {
        Uri uri = Uri.parse("android.resource://com.snu_artoon.arwebtoonplayer/drawable/"
                + fileName);
        destination.setImageURI(uri);
    }
}
 
开发者ID:Jamjomjara,项目名称:snu-artoon,代码行数:13,代码来源:LocalImageLoader.java

示例8: instantiateItem

import android.widget.ImageView; //导入方法依赖的package包/类
/**
 * Create the page for the given position.
 *
 * @param container The containing View in which the page will be shown.
 * @param i The page position to be instantiated.
 *
 * @return Returns an Object representing the new page. This does not need
 *         to be a View, but can be some other container of the page.
 */
@Override
public  Object instantiateItem(ViewGroup container, int i)
{
    ImageView mImageView = new ImageView(mContext);
    mImageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
    mImageView.setImageURI(Uri.parse(pictureItems.get(i).get_mainImg()));
    ((ViewPager)container).addView(mImageView,0);

    return  mImageView;


}
 
开发者ID:peterdestasio,项目名称:Geoclick,代码行数:22,代码来源:MyImageAdapter.java

示例9: bind

import android.widget.ImageView; //导入方法依赖的package包/类
private void bind(ProductEntity item, View view) {
    ImageView imgDressing = (ImageView) view.findViewById(R.id.img_item_dressing);
    int resId = item.getResId();
    if(resId <= 0){
        Uri uri = item.getUri();
        if(uri != null){
            imgDressing.setImageURI(uri);
        }
    }else {
        imgDressing.setImageResource(resId);
    }
}
 
开发者ID:Sugarya,项目名称:Closet,代码行数:13,代码来源:CardPagerAdapter.java

示例10: putImage

import android.widget.ImageView; //导入方法依赖的package包/类
private void putImage(ImageView imageView, Object data) {
    imageView.setImageBitmap( null );
    if( data == null ) {
        return;
    }
    if( data instanceof Bitmap ) imageView.setImageBitmap( ( Bitmap ) data);
    if( data instanceof Integer ) imageView.setImageResource(( Integer ) data);
    if( data instanceof Drawable ) imageView.setImageDrawable( ( Drawable ) data);
    if( data instanceof Uri ) imageView.setImageURI( ( Uri ) data);
    if( data instanceof Matrix ) imageView.setImageMatrix( ( Matrix ) data);
}
 
开发者ID:tec-ustp,项目名称:SIIEScanner,代码行数:12,代码来源:ItemRow.java

示例11: setImageUrl

import android.widget.ImageView; //导入方法依赖的package包/类
@Override
public HelperViewHolder setImageUrl(int viewId, String imgUrl) {
    ImageView imageView = getView(viewId);
    if (!TextUtils.isEmpty(imgUrl)) {
        imageView.setImageURI(Uri.parse(imgUrl));
    }
    return this;
}
 
开发者ID:xiaoyaoyou1212,项目名称:XSnow,代码行数:9,代码来源:HelperViewHolder.java

示例12: setViewImage

import android.widget.ImageView; //导入方法依赖的package包/类
public void setViewImage(ImageView v, String value) {
    try {
        v.setImageResource(Integer.parseInt(value));
    } catch (NumberFormatException e) {
        v.setImageURI(Uri.parse(value));
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:8,代码来源:SimpleCursorAdapter.java

示例13: setImgUri

import android.widget.ImageView; //导入方法依赖的package包/类
@BindingAdapter("imgUri")
public static void setImgUri(ImageView view, Uri uri) {
    try {
        view.setImageURI(uri);
    } catch (OutOfMemoryError error) {
        ToastUtil.toast(R.string.pic_too_large);
    }
}
 
开发者ID:foreveruseful,项目名称:smartkey,代码行数:9,代码来源:BindUtil.java

示例14: setViewImage

import android.widget.ImageView; //导入方法依赖的package包/类
/**
 * Called by bindView() to set the image for an ImageView but only if
 * there is no existing ViewBinder or if the existing ViewBinder cannot
 * handle binding to an ImageView.
 *
 * By default, the value will be treated as an image resource. If the
 * value cannot be used as an image resource, the value is used as an
 * image Uri.
 *
 * Intended to be overridden by Adapters that need to filter strings
 * retrieved from the database.
 *
 * @param v ImageView to receive an image
 * @param value the value retrieved from the cursor
 */
public void setViewImage(ImageView v, String value) {
    try {
        v.setImageResource(Integer.parseInt(value));
    } catch (NumberFormatException nfe) {
        v.setImageURI(Uri.parse(value));
    }
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:23,代码来源:SimpleDragSortCursorAdapter.java

示例15: getView

import android.widget.ImageView; //导入方法依赖的package包/类
@NonNull
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
    View view;

    if (convertView == null)
    {
        view = LayoutInflater.from(_activity).inflate(R.layout.picture_grid_item, parent, false);
    }
    else
    {
        view = convertView;
    }

    ImageView imageView = (ImageView)view.findViewById(R.id.image);

    imageView.setImageURI(null);

    final Picture picture = getItem(position);

    imageView.setOnClickListener(new View.OnClickListener()
    {
        @Override
        public void onClick(View v)
        {
            if(picture != null)
            {
                Bundle bundle = new Bundle();
                bundle.putString("file", picture.uri.getPath());
                Intent i = new Intent(_activity, PictureViewActivity.class);
                i.putExtras(bundle);
                _activity.startActivityForResult(i, REQUEST_VIEW_IMAGE_TAG);
            }
        }
    });

    if(picture != null)
    {
        Glide.with(_activity).load(picture.uri).centerCrop().into(imageView);
    }

    return imageView;
}
 
开发者ID:brarcher,项目名称:rental-calc,代码行数:45,代码来源:PropertyPicturesActivity.java


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