how to use photoview 2.0.0 in android studio 3

184 Views Asked by At

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

1

There are 1 best solutions below

1
On BEST ANSWER

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 );
}