vendredi 19 juillet 2019

How to use IF with Button in java Android?

i want to make button that move into new activity but in some condition. if i used button1 then show data about A, and if used button2 the show data about B.

i tried intent to new activity for each button but i have to make new class right? so thats why i just want used IF like i said before

Button move_found = findViewById(R.id.btn_found);
Button move_conc = findViewById(R.id.btn_conc);

move_found.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MakeupMenu.this, MakeupActivity.class);
                startActivity(intent);
            }
        });
move_conc.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MakeupMenu.this, MakeupActivity.class);
                startActivity(intent);
            }
        });

thats my code for each Button, how to put IF for each button? i must put the IF code in here (MakeupMenu.class) , or in a new activity named MakeActivity.class?

Aucun commentaire:

Enregistrer un commentaire