2016-02-04 38 views
0

我建立自定义的喜好和我读过这些帖子资源标识符:安卓:创建自定义的偏好 - 未找到属性

Android: Creating custom preference

Android Set Custom Preference Layout

在布局Text_description_value_referencePreference我有

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

<TextView 
    android:id="@android:id/title" 
    style="@android:style/TextAppearance.DeviceDefault.SearchResult.Title" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Title" /> 

<TextView 
    android:id="@android:id/summary" 
    style="@android:style/TextAppearance.DeviceDefault.SearchResult.Subtitle" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Summary" /> 

<TextView 
    android:id="@+id/currentvalue" 
    style="@android:style/TextAppearance.DeviceDefault.SearchResult.Subtitle" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Current Value Layout" /> 
</LinearLayout> 

类:

public class Text_description_value_referencePreference extends EditTextPreference { 

String currentvalue; 

// // https://stackoverflow.com/questions/28095643/android-set-custom-preference-layout 
public Text_description_value_referencePreference(Context context) { 
    super(context); 
} 

public Text_description_value_referencePreference(Context context, AttributeSet attrs) { 
    super(context, attrs); 
} 

// https://stackoverflow.com/questions/16108609/android-creating-custom-preference 
@Override 
protected View onCreateView(ViewGroup parent) 
{ 
    super.onCreateView(parent); 
    LayoutInflater li = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    return li.inflate(R.layout.text_description_value_reference, parent, false); 
} 
} 

偏好:

<com.julius.ble.Text_description_value_referencePreference 
     android:key="test" 
     android:title="title" 
     android:currentvalue="currentvalue"/> 

在的preferences.xml Studio为错误:

Error:(19) No resource identifier found for attribute 'currentvalue' in package 'android' 

Prerences工作瓦特/出这种添加的自定义currentvalue。清洁/重建不起作用。我错过了什么?

回答