android在非Activity下,intent页面跳转问题

来源:互联网 发布:js获取点击事件 编辑:程序博客网 时间:2024/05/01 01:34

在Activity下,我们知道页面的跳转如下:

Intent intent = new Intent();intent.setClass(当前Activity.this, 跳转到的Activity.class);startActivity(intent);

在非Activity下,例如自定义adapter.我们需要定义一个运行上下文来启动页面跳转:

private Context context;  //运行上下文   Intent intent = new Intent();intent.setClass(context,跳转到的Activity.class);context.startActivity(intent);

                                             
0 0
原创粉丝点击