简体   繁体   English

构造函数Intent(new ViewPager.OnPageChangeListener(){},类 <Player> )未定义

[英]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 我收到一条错误消息:构造函数Intent(新的ViewPager.OnPageChangeListener(){},类)未定义

on the line: Intent intent = new Intent(this, Player.class); 在行上: 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 如果此代码在Activity类(例如称为MainActivity)中,则可以使用此代码

Intent intent = new Intent(MainActivity.this, Player.class); You can reference the outer class by calling OuterClass.this 您可以通过调用OuterClass.this来引用外部类。

Change 更改

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

to

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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