gpt4 book ai didi

android - 为什么我需要在 ViewThread 构造函数中将面板类作为参数传递..?

转载 作者:行者123 更新时间:2023-11-29 02:11:30 24 4
gpt4 key购买 nike

         public class ViewThread extends Thread 
{
private Panel mPanel;
private SurfaceHolder mHolder;
private boolean mRun = false;

public ViewThread(Panel panel)
{
mPanel = panel;
mHolder = mPanel.getHolder();
}

为什么我需要将 Panel 类作为参数传递给 ViewThread 构造函数?

最佳答案

正如 Mitch 所说,构造函数需要一个 Panel 对象。如果你不想那样(虽然我想这是有原因的)你可以简单地写第二个构造函数,比如

         public class ViewThread extends Thread 
{
private Panel mPanel;
private SurfaceHolder mHolder;
private boolean mRun = false;

public ViewThread(Panel panel)
{
mPanel = panel;
mHolder = mPanel.getHolder();
}


public ViewThread()
{
// Do something constructive here, like
mPanel = new Panel();
}

关于android - 为什么我需要在 ViewThread 构造函数中将面板类作为参数传递..?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7048956/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com