我在 this.viewcam.setOnClickListerner(new view.OnClickListerner())
行中收到以下错误。
我在 eclipse 中遇到这个错误。
该行有多个标记
View
类型中的方法setOnClickListener(View.OnClickListener)
不适用于参数 (new OnClickListener(){}
)- View 无法解析为类型
public class Main extends Activity
implements View.OnClickListener
{
Button viewcam;
EditText editTextIp;
EditText login;
EditText passwd;
public void onCreate(Bundle paramBundle)
{
super.onCreate(paramBundle);
setContentView(R.layout.main);
this.viewcam = ((Button)findViewById(R.id.viewcam));
this.viewcam.setOnClickListener(new view.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
if (v == this.viewcam)
{
Log.i("login", this.login.getText().toString());
Log.i("Passwd", this.passwd.getText().toString());
Intent localIntent1 = new Intent(v.getContext(), MjpegSample.class);
Log.i("My ip", this.editTextIp.getText().toString());
localIntent1.putExtra("ip", "http://" + this.editTextIp.getText().toString() + "/");
localIntent1.putExtra("user", this.login.getText().toString());
localIntent1.putExtra("passwd", this.passwd.getText().toString());
startActivityForResult(localIntent1, 1000);
} }
});
this.editTextIp = ((EditText)findViewById(R.id.ip));
this.login = ((EditText)findViewById(R.id.username));
this.passwd = ((EditText)findViewById(R.id.password));
}
}
最佳答案
改变
this.viewcam.setOnClickListener(new view.OnClickListener() {
至
this.viewcam.setOnClickListener(new OnClickListener() {
关于java - 该行有多个标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10456451/