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
。清潔/重建不起作用。我錯過了什麼?