Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Connecting Login to Register Activty

Hi I have this code below which I think should connect a register text view to the register activity/layout:

protected void onCreate(Bundle savedInstanceState) {


    mRegisterTextView = (TextView)findViewById(R.id.register);
    mRegisterTextView.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(LoginActivity.this, RegisterActivity.class);
            startActivity(intent);            }


Here is the layout XML:

<TextView android:layout_marginTop="25dp" android:text="@string/RegisterTitle" android:id="@+id/register" android:layout_below="@id/login" style="@style/LinkBlue"/>

And the Register Class is named Register Activity.

I run the emulator and it does not seem to work...what am I missing?

Thanks so much


2 Answers

Yongshuo Wang
Yongshuo Wang
5,500 Points

I think you need setOnClickListener to a button, in your code, you add this to your TextView.

Hi So, it needs to be a button?

I have this: < TextView android:layout_marginTop="25dp" android:text="@string/RegisterTitle" android:id="@+id/register" android:layout_below="@id/login" style="@style/LinkBlue"/