Answer the question
In order to leave comments, you need to log in
How can I add a ViewPager to a class?
Good afternoon. I'm starting to learn programming for android. I found a tutorial where you can change screens with a swipe (left-right). When I got to the declaration of ViewPager in MainActivity, I ran into an error (Expecting member declaration).
Here is the code:
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
class IntroActivity : AppCompatActivity() {
private ViewPager screenPager;
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_intro)
//setup ViewPager
screenPager = findViewById(R.id.screen_viewpager)
}
}
private ViewPager screenPager;and doesn't work.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question