Final Getter Method throws Exception, but required in onClickListener as final

-5

I use

final String layoutName = view.getResources().getResourceEntryName(view.getId());

to get the layouts xml name; like fragment_login. I need this to be final because it is used in a onClick listener in the next line:

    loginButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
           Timber.d("Useage of " + layoutName); 
        }
    })

So far so good. But the getResourceEntryName() throws every now and then a

android.content.res.Resources$NotFoundException: Unable to find resource ID #0xffffffff

When I catch it, its hard to leave it as final.

How can I solve my problem easily?

java
android
asked on Stack Overflow Feb 14, 2019 by Tranquillo • edited Feb 14, 2019 by Tranquillo

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0