SettingsActivity模板

时间:2013-12-07 21:14:36

标签: android android-fragments

我有一个简单的问题。我创建了活动表单模板(SettingsActivity) - 使用eclipse和ADT,这个模板工作正常但是当我在平板电脑上运行这个模板应用程序时,设置显示在两列中的列表中。我认为当我们在平板电脑上使用标题的双窗格视图时会自动创建。我必须添加哪些内容才能在平板电脑上以双窗格模式显示设置?

1 个答案:

答案 0 :(得分:0)

当我使用向导创建一个Preference活动时,我也得到以下代码,你确定你没有它吗?

这些确定何时显示两个窗格视图。

/** {@inheritDoc} */
@Override
public boolean onIsMultiPane() {
    return isXLargeTablet(this) && !isSimplePreferences(this);
}

/**
 * Helper method to determine if the device has an extra-large screen. For
 * example, 10" tablets are extra-large.
 */
private static boolean isXLargeTablet(Context context) {
    return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
}

/**
 * Determines whether the simplified settings UI should be shown. This is
 * true if this is forced via {@link #ALWAYS_SIMPLE_PREFS}, or the device
 * doesn't have newer APIs like {@link PreferenceFragment}, or the device
 * doesn't have an extra-large screen. In these cases, a single-pane
 * "simplified" settings UI should be shown.
 */
private static boolean isSimplePreferences(Context context) {
    return ALWAYS_SIMPLE_PREFS || Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB || !isXLargeTablet(context);
}