AS-cannot resolve constructor intent

来源:互联网 发布:dota后期三大核 知乎 编辑:程序博客网 时间:2024/06/05 04:51
喵呜,好烦,又cannont resolve,在这种情况下遇到的
 Intent intent = new Intent(this,emergencyIntent.class);、、
解决:
 Intent intent = new Intent(MainActivity.this,emergencyIntent.class);
原因:
The error is because you are writing it in public void onClick(View v), where 'this' will mean instance of anonymous class that implements View.OnClickListener. while first parameter in Intent constructor Intent(Context context, Class<?> cls) requires Activity context.


原创粉丝点击