2011-01-20 2 views
0

친구, 실제로 내가 텍스트 상자와 함께 이미지를 그리려는 다음 등 위의 제어 다음 아래 prefrences 루트 레벨에 왜 사용 RelativeLayout의 이잖아PrefrenceScreen 기본 구현 문제? 나는 다음과 같은 XML을 사용하고

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout android:layout_height="fill_parent" android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"> 
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> 
     <PreferenceCategory 
       android:title="First Category"> 
       <ListPreference 
         android:title="List Preference" 
         android:summary="This preference allows to select an item in a array" 
         android:key="listPref" 
         android:defaultValue="digiGreen" 
         android:entries="@array/justforme_title_array" 
         android:entryValues="@array/sub_justforme_array" /> 
     </PreferenceCategory> 


</PreferenceScreen> 

</RelativeLayout> 

및 자바 코드

public void onCreate(Bundle savedInstanceState) { 
super.onCreate(savedInstanceState); 

     setContentView(R.layout.justforme); 

} 

는 오류

01-20 15:07:54.412: ERROR/AndroidRuntime(648): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.abc/com.abc.JustForMe}: android.view.InflateException: Binary XML file line #3: Error inflating class PreferenceScreen 

도움이 다음 날주고하는 감사하겠습니다.

답변

0

나는 PreferenceScreen이 xml 파일 맨 위에 있어야한다고 생각합니다. 레이아웃에 캡슐화 할 필요가 없습니다. ralativelayout을 제거하려고 : 당신은 당신을 위해 작동이 두 sloutions에서 루트 level.maybe에서 상대 레이아웃을 사용하는 것처럼 내가 코드에서 생각하는 문제가

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> 
     <PreferenceCategory 
       android:title="First Category"> 
       <ListPreference 
         android:title="List Preference" 
         android:summary="This preference allows to select an item in a array" 
         android:key="listPref" 
         android:defaultValue="digiGreen" 
         android:entries="@array/justforme_title_array" 
         android:entryValues="@array/sub_justforme_array" /> 
     </PreferenceCategory>  
</PreferenceScreen> 
0

: 한 번에 하나의 시도.


1 :) 루트에서 상대 layotu를 제거하면 ramainig 코드는 여기에 붙여 넣은 것과 동일합니다.


2) : xmlns : attribute를 preferencescreen 태그에서 제거하십시오.

+0

yaar 두 번째 옵션은 의미가 없습니다. 하지만 첫번째 감사합니다 .. – UMAR

+0

umar 나는이 속성이 루트 엘에만있을 것이라고 tht ption bcoz를주었습니다. –

관련 문제