android程序怎么导入图片不显示,android – ImageViewZoom中不显示图像

我想在

ImagePagerActivity中使用

ImageViewZoom和

Universal Image Loader.

那么,我做了什么:

>我将imageviewtouch.jar添加到项目类路径中.

>在ImagePagerActivity中,我在instantiateItem()函数中更改了一行.我评论了ImageView的位置,并将其替换为ImageViewTouch(4.和5.行)

@Override

public Object instantiateItem(View view, int position) {

final View imageLayout = inflater.inflate(R.layout.item_pager_image, null);

//final ImageView imageView = (ImageView) imageLayout.findViewById(R.id.image);

final ImageViewTouch imageView = (ImageViewTouch) imageLayout.findViewById(R.id.image);

final ProgressBar spinner = (ProgressBar) imageLayout.findViewById(R.id.loading);

final TextView textView = (TextView)imageLayout.findViewById(R.id.text);

imageLoader.displayImage(images[position], imageView, options, new ImageLoadingListener() {

public void onLoadingStarted() {

spinner.setVisibility(View.VISIBLE);

}

public void onLoadingFailed(FailReason failReason) {

String message = null;

switch (failReason) {

case IO_ERROR:

message = "Input/Output error";

break;

case OUT_OF_MEMORY:

message = "Out Of Memory error";

break;

case UNKNOWN:

message = "Unknown error";

break;

}

Toast.makeText(ImagePagerActivity.this, message, Toast.LENGTH_SHORT).show();

spinner.setVisibility(View.GONE);

imageView.setImageResource(android.R.drawable.ic_delete);

}

public void onLoadingComplete(Bitmap loadedImage) {

spinner.setVisibility(View.GONE);

Animation anim = AnimationUtils.loadAnimation(ImagePagerActivity.this, R.anim.fade_in);

imageView.setAnimation(anim);

anim.start();

}

public void onLoadingCancelled() {

// Do nothing

}

});

((ViewPager) view).addView(imageLayout, 0);

return imageLayout;

}

>在/res/layout/item_pager_image.xml中我将ImageView替换为it.sephiroth.android.library.imagezoom.ImageViewTouch

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:padding="1dip" >

android:layout_weight="1"

android:id="@+id/image"

android:layout_width="match_parent"

android:layout_height="0dp"

android:scaleType="fitCenter" />

android:id="@+id/loading"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center"

android:visibility="gone" />

我运行这个Android应用程序,但是当我在菜单屏幕中选择Image Pager时,没有显示图像,只有黑屏.在logcat中,我看到图像已下载并显示…如果我将ImageViewTouch更改为原始ImageView,一切正常,但当然没有缩放功能.如果有人知道我做错了什么,我会非常感激. (对不起我的英语不好)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值