【发布时间】:2011-01-18 02:45:15
【问题描述】:
我最近问了这个问题的前身,得到了很好的答复。但是,当我在我的 android 应用程序中使用这个时,我遇到了一个意外错误,我想知道是否每个人都可以查看我的代码并帮助我看看我做错了什么。
初始问题的链接:passing reference of class to another class
我的错误:“构造函数 ConnectDevice(new View.OnClickListener(){}) 未定义”
以上是eclipse检测到的错误。
提前致谢!
下面是我的代码sn-ps:
public class SmartApp extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.intro);
final Button connectDeviceButton = (Button) findViewById(R.id.connectDeviceButton);
connectDeviceButton.setOnClickListener(
new View.OnClickListener()
{
@Override
public void onClick(View v) {
Thread cThread = new Thread(new ConnectDevice(this));
cThread.start();
}
});
}
}
public class ConnectDevice implements Runnable {
private boolean connected;
private SmartApp smartAppRef;
private ObjectInputStream ois;
public ConnectDevice(SmartApp smartAppRef) {
this.smartAppRef = smartAppRef;
}
}
【问题讨论】:
标签: java android class reference