Quantcast
Channel: Active questions tagged crash - Stack Overflow
Viewing all articles
Browse latest Browse all 7194

Multiple buttons on same Activity

$
0
0

Firstly let me thank you for looking at the very least. I'm still very new to development but I successfully now have a decent splash screen working moving towards getting the sign up and login activities to show after button presses. The below code is working for the login activity but my app crashes after pressing the signup button. I suspect I'm doing something stupid but I've tried a few several ways to introduce these buttons and make them work but nothing seems to.

public class SplashActivity extends AppCompatActivity {    private ImageView iconImageView;    private Button SignUpBtn, LoginBtn;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_splash);        SignUpBtn = findViewById(R.id.SignUpBtn);        SignUpBtn.setOnClickListener((v) ->{            Intent intent = new Intent(SplashActivity.this, SignUpActivity.class);            startActivity(intent);        }        LoginBtn = findViewById(R.id.LoginBtn);        LoginBtn.setOnClickListener((v) ->{            Intent in = new Intent(SplashActivity.this, LoginActivity.class);            startActivity(in);        });    }}public class SignUpActivity extends AppCompatActivity {    TextView createTextView;    LinearLayout facebookLinearLayout, twitterLinearLayout, googlePlusLinearLayout;    Button registerButton;    ImageView bgImageView;    Button forgotButton;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_sign_up);        initUI();        initDataBindings();        initActions();    }    //region Init Functions    private void initUI() {        forgotButton = findViewById(R.id.forgotButton);        facebookLinearLayout = findViewById(R.id.facebookLinearLayout);        twitterLinearLayout = findViewById(R.id.twitterLinearLayout);        googlePlusLinearLayout = findViewById(R.id.googlePlusLinearLayout);        registerButton = findViewById(R.id.registerButton);        bgImageView = findViewById(R.id.bgImageView);    }    private void initDataBindings() {        int id = R.drawable.lightbg;        Utils.setImageToImageView(getApplicationContext(), bgImageView, id);    }    private void initActions() {        forgotButton.setOnClickListener(view -> {            Toast.makeText(getApplicationContext(), "Clicked Forgot Password", Toast.LENGTH_SHORT).show();        });        createTextView.setOnClickListener(view -> {            Toast.makeText(getApplicationContext(), "Clicked Create Account", Toast.LENGTH_SHORT).show();        });        facebookLinearLayout.setOnClickListener(view -> {            Toast.makeText(getApplicationContext(), "Clicked Facebook", Toast.LENGTH_SHORT).show();        });        twitterLinearLayout.setOnClickListener(view -> {            Toast.makeText(getApplicationContext(), "Clicked Twitter", Toast.LENGTH_SHORT).show();        });        googlePlusLinearLayout.setOnClickListener(view -> {            Toast.makeText(getApplicationContext(), "Clicked Google Plus", Toast.LENGTH_SHORT).show();        });        registerButton.setOnClickListener(view -> {            Toast.makeText(getApplicationContext(), "Clicked Sign Up", Toast.LENGTH_SHORT).show();        });    }    //endregion}

Viewing all articles
Browse latest Browse all 7194

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>