2013-12-07 1 views
0

간단한 질문이 있습니다. 나는 활동 양식 템플릿 (SettingsActivity)을 만들었습니다. 이클립스와 ADT를 사용하면이 템플릿은 정상적으로 작동하지만 태블릿에서이 템플릿 앱을 실행하면 두 열에 목록 번호가 표시됩니다. 헤더의 두 창보기를 사용하면 태블릿에서 자동으로 작성됩니다. 태블릿에서 두 개의 창 모드로 설정을 표시하려면 무엇을 추가해야합니까?SettingsActivity 템플릿

+0

도움이 될 수 있도록 몇 가지 코드를 제공하십시오. – ismail

+0

조각을 사용합니까? 코드를 보여주십시오. – 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