1

SetOnClickListener 有错误。它表示方法 SetOnClickListener(new View.OnClickListener(){}) 未定义 TextView 类型。为什么?

package com.example.testing;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class RegisterActivity extends Activity 
{
@Override
    public void onCreate(Bundle savedInstanceState)
    {

        super.onCreate(savedInstanceState);
        //Set View to register.xml
        setContentView(R.layout.register);

        TextView loginScreen = (TextView) findViewById (R.id.link_to_login);

        //Listening to Login Screen Link
        loginScreen.SetOnClickListener(new View.OnClickListener()
        {

            public void onClick(View arg0)
            {
                //Closing reg screen
                //Switching to Login Screen/closing reg screen
                finish();
            }
        });
    }
}
4

1 回答 1

1

改成

loginScreen.setOnClickListener(new View.OnClickListener()
{

并导入

import android.view.View.OnClickListener;

并添加@Override 注解

@Override
public void onClick(View arg0)
{
于 2013-11-10T05:23:44.490 回答