castingphotophoto-galleryandroid-photoview

how to use photoview 2.0.0 in android studio 3


I have a problem with photoview lib from gihub... How can I cast my image to the photoview? I have a error in .java file and no more ...!!!

enter image description here

and it is a image of my XML file

enter image description here


Solution

  • You should put it inside in onCreate and not outside.

    protected void onCreate(Bundle bundle){
       super.onCreate(bundle);
       setContentView(R.layout.activity_main);
    
       PhotoView view = (PhotoView) findViewById(R.id.photo_view);
       view.setImageResource( your-image-here );
    }