Reputation: 1
Having issues with the line I labelled. Tried multiple different suggestions but none seem to fix the issue, anyone has anymore suggestions?
package connect2you.com;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
findViewById(R.id.textViewSignup).setOnClickListener(this); // error on this line
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.textViewSignup:
startActivity(new Intent(this, SignUpActivity.class));
break;
}
}
}
Upvotes: 0
Views: 963
Reputation: 151
Put your call tobfindViewById()
inside a method. You can't run code outside of methods.
Upvotes: 1