findViewById错误-子采样比例图像视图-Android
我试图测试本教程“子采样比例图像视图”中的代码,以进行缩放图像压缩,但它在.findviewbyd(id.imageView)上给出了一个错误;-无法解析符号 我的XML布局:findViewById错误-子采样比例图像视图-Android,android,image,zooming,scale,subsampling,Android,Image,Zooming,Scale,Subsampling,我试图测试本教程“子采样比例图像视图”中的代码,以进行缩放图像压缩,但它在.findviewbyd(id.imageView)上给出了一个错误;-无法解析符号 我的XML布局: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
谁能帮帮我吗
提前谢谢
CAFC快速解决方案:将
id.imageView
替换为R.id.imageView
SubsamplingScaleImageView imageView = (SubsamplingScaleImageView)findViewById(R.id.imageView);
imageView.setImage(ImageSource.resource(R.drawable.abc));
发生的事情是,当您想要引用一个ID时,您可以转到android提供的R
(参考资料)目录。您必须转到资源目录(R
),然后在那里有id
目录。然后是您的id。因此,最终结果是R.id.imageView
SubsamplingScaleImageView imageView = (SubsamplingScaleImageView)findViewById(R.id.imageView);
imageView.setImage(ImageSource.resource(R.drawable.abc));
您已错过了
R.id.imageView
-6次向下投票。。。WowI不知道为什么他们6次否决了这个答案。投了一票,真是一堆废话。