这条线上有多个标记

时间:2012-05-04 21:35:51

标签: java android eclipse

我在this.viewcam.setOnClickListerner(new view.OnClickListerner())行中收到以下错误 我在eclipse中得到了这个错误。

此行有多个标记

  • 类型setOnClickListener(View.OnClickListener)中的方法View不适用于参数(new OnClickListener(){}
  • 视图无法解析为类型
    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));

}
  }

2 个答案:

答案 0 :(得分:1)

更改

 this.viewcam.setOnClickListener(new view.OnClickListener() {

 this.viewcam.setOnClickListener(new OnClickListener() {

答案 1 :(得分:0)

您需要在

中大写查看
this.viewcam.setOnClickListener(new view.OnClickListener() {

所以它应该是

this.viewcam.setOnClickListener(new View.OnClickListener() {