简体   繁体   English

对于new View.OnClickListener(){}类型,未定义方法overridePendingTransition(int,int)

[英]The method overridePendingTransition(int, int) is undefined for the type new View.OnClickListener(){}

I tried to add animation on start activity intent and I got this error. 我尝试在开始活动意图上添加动画,但出现此错误。 It's the first time I've seen something like this, I looked up on google and SO but I was unable to find anything that would help me solve this issue. 这是我第一次看到这样的内容,我在google和SO上进行了查找,但找不到任何能帮助我解决此问题的内容。 So how can I fix this? 那么我该如何解决呢? Whats wrong with my code? 我的代码有什么问题?

holder.transfer.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            @SuppressWarnings("unused")
            int clickedposition = (Integer) v.getTag();
            Intent iv = new Intent(context,
                    MenuActivity.class);

            if (iv != null) {
                iv.putExtra("NAME", ringNames[position]);
                int [] res = songPos;
                iv.putExtra("PATH", res[position]);
                iv.putExtra("FILE", ringNames[position]+".mp3");
                ((Activity) context).startActivity(iv);
                overridePendingTransition(R.anim.push_down_in,R.anim.push_down_out);
            }

                 try
                  {
                    CentralActivity.playing = Boolean.valueOf(false);
                    CentralActivity.mp.stop();
                    CentralActivity.mp.release();

                    return;
                  }
                  catch (Exception localException)
                  {

                  }

        }
    });

I get error The method overridePendingTransition(int, int) is undefined for the type new View.OnClickListener(){} thanks 我收到错误对于新View.OnClickListener(){}类型,未定义方法overridePendingTransition(int,int),谢谢

Replase your: 更换您的:

overridePendingTransition(R.anim.push_down_in,R.anim.push_down_out);

To: 至:

 ((Activity) context).overridePendingTransition(R.anim.push_down_in,R.anim.push_down_out);

You need to call methdod overridePendingTransition from activity, but you do it in OnClickListener . 你需要调用methdod overridePendingTransition从一个活动,但你在做OnClickListener

try this: 尝试这个:

Intent iv = new Intent(CurrentActivity.this
                    MenuActivity.class);

            if (iv != null) {
                iv.putExtra("NAME", ringNames[position]);
                int [] res = songPos;
                iv.putExtra("PATH", res[position]);
                iv.putExtra("FILE", ringNames[position]+".mp3");
                startActivity(iv);
                overridePendingTransition(R.anim.push_down_in,R.anim.push_down_out);
            }

暂无
暂无

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

相关问题 方法findViewByID(int)未定义类型new View.OnClickListener(){} - The method findViewByID(int) is undefined for the type new View.OnClickListener(){} 如何解决错误:getSharedPreferences(String,int)未定义类型new View.OnClickListener(){} - How to resolve an error: getSharedPreferences(String, int) is undefined for the type new View.OnClickListener(){} Android对于new View.OnClickListener(){}类型,未定义方法startActivity(Intent) - Android The method startActivity(Intent) is undefined for the type new View.OnClickListener(){} 未为类型imageButton1定义方法setOnClickListener(new View.OnClickListener(){}) - The method setOnClickListener(new View.OnClickListener(){}) is undefined for the type imageButton1 Android-未定义类型为new View.OnClickListener(){}的Sqlite数据库方法 - Android - Sqlite database method undefined for type new View.OnClickListener(){} 对于新视图类型,未定义方法startactivity(intent)。onclicklistener() - the method startactivity(intent) is undefined for the type new view.onclicklistener() 对于新的View.OnClickListener(){}类型,未定义方法userAccounts() - The method userAccounts() is undefined for the type new View.OnClickListener(){} 未定义类型为new View.OnClickListener(){} - Undefined for the type new View.OnClickListener(){} 如何修复类型为new View.OnClickListener()语法错误的方法startActivity(Intent)未定义 - How to fix The method startActivity(Intent) is undefined for the type new View.OnClickListener() syntax error 新的View.OnClickListener类型必须实现继承的抽象方法 - The type new View.OnClickListener must implement the inherited abstract method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM