Android 设置活动模板

Android 设置活动模板,android,android-fragments,Android,Android Fragments,我有一个简单的问题。我使用eclipse和ADT创建了活动表单模板(SettingsActivity),该模板工作正常,但当我在平板电脑上运行该模板应用程序时,设置显示在两列的列表no中。我认为当我们在平板电脑上使用header的两个窗格视图时,它是自动装箱的。在平板电脑上以双窗格模式显示设置时,我必须添加什么?当我使用向导创建首选项活动时,我也会得到以下代码,您确定没有吗 它们决定何时显示该双窗格视图 /** {@inheritDoc} */ @Override public boolean

我有一个简单的问题。我使用eclipse和ADT创建了活动表单模板(SettingsActivity),该模板工作正常,但当我在平板电脑上运行该模板应用程序时,设置显示在两列的列表no中。我认为当我们在平板电脑上使用header的两个窗格视图时,它是自动装箱的。在平板电脑上以双窗格模式显示设置时,我必须添加什么?

当我使用向导创建首选项活动时,我也会得到以下代码,您确定没有吗

它们决定何时显示该双窗格视图

/** {@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);
}
/**{@inheritDoc}*/
@凌驾
公共布尔值onIsMultiPane(){
返回isxlargetable(此)和&!isSimplePreferences(此);
}
/**
*确定设备是否有超大屏幕的辅助方法。对于
*例如,10英寸的平板电脑是特大型的。
*/
私有静态布尔值isxlargetable(上下文){
返回(context.getResources().getConfiguration().screenLayout&Configuration.screenLayout\u SIZE\u MASK)>=Configuration.screenLayout\u SIZE\u XLARGE;
}
/**
*确定是否应显示简化设置UI。这是
*如果通过{@link#ALWAYS _SIMPLE _PREFS}或设备强制执行,则为true
*没有更新的API,如{@link PreferenceFragment},或设备
*没有超大屏幕。在这种情况下,只有一个窗格
*应显示“简化”设置界面。
*/
私有静态布尔值首选项(上下文){
返回始终| SIMPLE | PREFS | Build.VERSION.SDK | INT
给出一些代码,这样就可以帮助您使用片段了吗?显示您的代码。对不起,我现在添加了代码:)您在哪个API上运行此功能,平板电脑的屏幕大小是多少?API 18。我在Genymotion emulator上以nexus 7(1280x800)的形式对其进行了测试。