Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
findViewById错误-子采样比例图像视图-Android_Android_Image_Zooming_Scale_Subsampling - Fatal编程技术网

findViewById错误-子采样比例图像视图-Android

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" >

我试图测试本教程“子采样比例图像视图”中的代码,以进行缩放图像压缩,但它在.findviewbyd(id.imageView)上给出了一个错误;-无法解析符号

我的XML布局:

<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次否决了这个答案。投了一票,真是一堆废话。