-5

I have a tutorial video, in Video teacher can use setAdapter as you see below Image, but in my code, android studio not Recognize it

image of teacher learning: enter image description here

and below is my code screenshot: enter image description here

antonio
  • 57
  • 7
  • 1
    it is with lower case v. Read the compile time error and try to understand what it means before posting it – Blackbelt Jul 27 '16 at 07:45

2 Answers2

3

Replace

ViewPager.setAdapter(...

with

viewPager.setAdapter(...

ViewPager (with a capital letter) is a class name and by using it here, you are trying to access the static method of that class. There is no static method setAdapter and hence the error.

For readability, replace viewPager with pager. It will make it easier for you to avoid such mistakes and the code will be more readable :-)

Kelevandos
  • 7,024
  • 2
  • 29
  • 46
1

Write viewpager.setAdapter instead of ViewPager.setAdapter

By writing ViewPager.setAdapter you try to execute class method, not object method. But ViewPager.class has no such method, only instance of it.

Michael Spitsin
  • 2,539
  • 2
  • 19
  • 29