我的 XML 代码有一些问题,希望您能帮助我。
我在这个包中有这个类:
package com.example.myview
public class CustomDialog extends DialogPreference {
public CustomDialog(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
public CustomDialog(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
}
然后我有这个偏好 xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<com.example.myview.CustomDialog
android:dialogMessage="Are you sure you wish delete you account"
android:key="deleteAccountPreference"
android:negativeButtonText="Cancel"
android:positiveButtonText="Okay"
android:summary="@string/preferences_deleteaccount_summary"
android:title="@string/preferences_deleteaccount_title" />
</PreferenceScreen>
当我运行代码时,出现此错误:
03-16 17:03:18.032: E/AndroidRuntime(20224): android.view.InflateException: Binary XML file line #4: Error inflating class com.example.myview.CustomDialog
...
03-16 17:03:18.032: E/AndroidRuntime(20224): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.myview.CustomDialog" on path: .
总结一下我的问题,我想知道如何更改 xml 文件正在查看的路径,或者弄清楚为什么它不能扩展我的自定义视图。
提前致谢 :)