B
B
BitNeBolt2021-01-29 16:32:13
Android
BitNeBolt, 2021-01-29 16:32:13

How to check which button was pressed?

Hung the listener on Bottom Nav. I want that when I click on the desired tab, the corresponding fragment opens. To do this, I take the id from the MenuItem and check it in the switch. The studio issues the following warning:
60140e0d84eb2410280469.png

Is it safe to do such a check, or is there a more reliable way?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2021-01-29
@BitNeBolt

do if() {} else if()...
or stop writing java and use kotlin.
Here the studio just tells you that this code will break in the future. It will not work incorrectly, but will simply stop compiling.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question