How to use shared preference to update the layout using data binding

Updated 10 June 2017

Save

In this example, I used data binding on the navigation drawer to update the layout whenever a user logged in the navigation drawer change its layout. Make a class which extends a BaseObservable class and put a key in shared preference so whenever the value changes on the particular key shared preference listener notify the login variable.

Here is my public class LoginChecker:

In my login.xml,  data is an instance of LoginChecker class. Here the magic happens whenever the user logged in there is visibility condition so whenever the new value update on the index login in shared preference previous layout change its visibility.

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home