简体   繁体   中英

The constructor Intent(new ViewPager.OnPageChangeListener(){}, Class<Player>) is undefined

I'm getting an error stating: The constructor Intent(new ViewPager.OnPageChangeListener(){}, Class) is undefined

on the line: Intent intent = new Intent(this, Player.class);

and I'm not sure how this can be corrected. Has anyone incountered anything like this before? I thought using an intent in this format was pretty standard.

        @Override
        public void onPageSelected(int pos) {

            Intent intent = new Intent(this, Player.class);
            intent.putExtra("playlist", playlist);

        }

If this code is in a Activity class for example called MainActivity, you can use this

Intent intent = new Intent(MainActivity.this, Player.class); You can reference the outer class by calling OuterClass.this

Change

Intent intent = new Intent(this, Player.class);

to

Intent intent = new Intent(YourActivity.this, Player.class);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM