我有一个包含两个布局的活动的应用程序:
通常,我使用以下方法检查功能的细节方面:
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;
}如何将这种方法转换为使用数据绑定?
发布于 2016-07-07 14:59:07
您可以简单地在strings.xml文件中定义一个资源。
在值/strings.xml s.xml中。
<bool name="is_tablet">false</bool>在值中-w900dp/trac.xml
<bool name="is_tablet">true</bool>从代码中的任何位置访问此资源。这应该能解决你的问题。
例如:
boolean isTablet = getResources().getBoolean(R.bool.is_tablet);https://stackoverflow.com/questions/38248541
复制相似问题