2012-08-08 4 views
1

<include layout=""/> 태그를 사용하여 다른 레이아웃에 레이아웃을 포함하는 방법과 같이 레이아웃에 환경 설정을 포함 할 수 있습니까?레이아웃에 환경 설정 포함 방법

내 레이아웃 코드 내가 선호 @xml/set_variables을 포함하려고하지만 난 <include layout="@xml/set_variables"/> 주석을 제거하면 내 응용 프로그램이 충돌합니다 위의 레이아웃이

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical"> 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 

    android:padding="@dimen/padding_medium" 
    android:text="@string/hello_world" 
    tools:context=".MainActivity" /> 

<include layout="@layout/settings"/> 
<!-- <include layout="@xml/set_variables"/> --> 
</LinearLayout> 

처럼 간다. 레이아웃에 환경 설정을 포함시킬 수있는 방법이 있는지 또는 아무 것도 잊지 않도록 제안 할 수 있습니까?

답변

0

내가 this Link 겪었 내가

setContentView(R.layout.settings); 
addPreferencesFromResource(R.xml.set_variables); 

을 추가하고 내 요구 사항을 충족

<ListView 
    android:id="@android:id/list" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" /> 

settings 레이아웃에 ListView을 추가 한 Y PreferenceActivitonCreate에서 솔루션 을 발견