Reputation: 4177
I've got an application with an activity containing 2 layouts:
Normally, I check the detail side of functionality with:
if (findViewById(R.id.application_detail_container) != null) {
// The detail container view will be present only in the
// large-screen layouts (res/values-w900dp).
// If this view is present, then the
// activity should be in two-pane mode.
mTwoPane = true;
}
How can I convert such approach to use data binding?
Upvotes: 4
Views: 2968
Reputation: 3026
You could simply define a resource in your strings.xml file
In values/strings.xml.
<bool name="is_tablet">false</bool>
In values-w900dp/string.xml
<bool name="is_tablet">true</bool>
Access this resource from any where in your code. This should solve your issue.
For example :
boolean isTablet = getResources().getBoolean(R.bool.is_tablet);
Upvotes: 11