我正在构建自定义偏好设置,并且我已阅读这些帖子:
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
。清洁/重建没有帮助。我错过了什么?
答案 0 :(得分:0)
答案在这里: error: No resource identifier found for attribute 'adSize' in package 'com.google.example' main.xml
xmlns:app="http://http://schemas.android.com/apk/lib/YourPackageName"
app:currentvalue="Current Value"