【问题标题】:How to make a class that extends SurfaceView start an Activity?如何让扩展 SurfaceView 的类启动 Activity?
【发布时间】:2011-06-16 05:32:54
【问题描述】:

所以我有一个类可以在我的游戏中绘制并完成所有提升,它扩展了 SurfaceView。 我想开始一个新的活动,显示玩家死后的得分。 GameOver 活动有得分。 我该怎么做?

【问题讨论】:

    标签: android android-activity surfaceview


    【解决方案1】:
    Context context = getContext(); // from MySurfaceView/Activity
    Intent intent = new Intent(context, GameOver.class);
    context.startActivity(intent);
    

    【讨论】:

    • 只是想补充一下,您也可以通过上面示例中的 Intent 将您的游戏数据从 SurfaceView 传递到 Activity
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多