2010年10月アーカイブ

               <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="メッセージ"
            />

という感じ。

このアーカイブについて

このページには、2010年10月に書かれたブログ記事が新しい順に公開されています。

前のアーカイブは2010年9月です。

次のアーカイブは2010年11月です。

最近のコンテンツはインデックスページで見られます。過去に書かれたものはアーカイブのページで見られます。

Powered by Movable Type 5.13-ja