android intent 在打开设置activity的时候在监听事件的内部 适用setclass()方法时 不是直接适用this 关键字
Student student= new Student();
student.setAge("19");
student.setName("hzf");
Intent intent = new Intent();
intent.setClass(MainActivity.this, Next_desplay_activity.class);//这里直接适用this 关键字会报错,应该适用MainActivity.this
intent.putExtra("mydata", student);
startActivity(intent);
错误提示:
The method setClass(Context, Class<?>) in the type Intent is not applicable for the arguments (new View.OnClickListener(){},
Class<Next_desplay_activity>)