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