本文整理匯總了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;
}