本文整理汇总了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();
}
}
示例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();
}
});
}
示例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);
}
});
}
示例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();
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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));
}
}
示例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);
}
}
示例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));
}
}
示例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;
}