<DialogPreference
android:title="ダイアログ"
android:summary="サマリー"
android:dialogTitle="ダイアログ"
android:dialogMessage="メッセージ"
/>
という記述で PreferenceActivity に DialogPreference を使おうと思ったら実行時に
ERROR AndroidRuntime RuntimeException Unable to start activity
ComponentInfo{}: android.view.InflateException: Binary XML file line
#60: Error inflating class java.lang.reflect.Constructor
というエラー。
調べてみたら、android 1.6 では DialogPreference は抽象クラスなのでインスタンス化のときにエラーになるのだそう。
対応としては、DialogPreference を継承して具象クラスを作り、具象クラスをXMLで指定する。
import android.content.Context;
import android.preference.DialogPreference;
import android.util.AttributeSet;
public class WorkingDialogPreference extends DialogPreference {
public WorkingDialogPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public WorkingDialogPreference(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
}
}
XMLは
<xxx.yyyy.WorkingDialogPreference
android:title="ダイアログ"
android:summary="サマリー"
android:dialogTitle="ダイアログ"
android:dialogMessage="メッセージ"
/>
という感じ。
android:title="ダイアログ"
android:summary="サマリー"
android:dialogTitle="ダイアログ"
android:dialogMessage="メッセージ"
/>
という記述で PreferenceActivity に DialogPreference を使おうと思ったら実行時に
ERROR AndroidRuntime RuntimeException Unable to start activity
ComponentInfo{}: android.view.InflateException: Binary XML file line
#60: Error inflating class java.lang.reflect.Constructor
というエラー。
調べてみたら、android 1.6 では DialogPreference は抽象クラスなのでインスタンス化のときにエラーになるのだそう。
対応としては、DialogPreference を継承して具象クラスを作り、具象クラスをXMLで指定する。
import android.content.Context;
import android.preference.DialogPreference;
import android.util.AttributeSet;
public class WorkingDialogPreference extends DialogPreference {
public WorkingDialogPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public WorkingDialogPreference(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
}
}
XMLは
<xxx.yyyy.WorkingDialogPreference
android:title="ダイアログ"
android:summary="サマリー"
android:dialogTitle="ダイアログ"
android:dialogMessage="メッセージ"
/>
という感じ。