Answer the question
In order to leave comments, you need to log in
Is it possible to assign multiple commands to one Button?
Is it possible to assign multiple commands to one Button? In one activity, for example, so that several types of text are displayed in turn.
Answer the question
In order to leave comments, you need to log in
If I understand correctly what you need, then you can of course create an external variable and use it instead of a flag, like this:
private int state = 0;
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (state == 0) {
//показываем первый кусок
state = 1;
}
else if (state == 1) {
//показываем второй кусок
state = 2
}
else {
//тут действие по умолчанию
}
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question