2013-12-07 57 views
0

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

+0

给一些代码,以便可以帮助 – ismail

+0

你使用Fragments吗?显示你的代码。 – Sigrlami

+0

对不起,我现在添加了代码:) – Bakus123

回答

0

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

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

/** {@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); 
} 
+0

你测试了这个代码,它的工作原理? – Bakus123