環境設定を使用してユーザー入力を EditTextPreference ボックスに保存し、後で使用するために取得するにはどうすればよいでしょうか。
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.prefs);
this.editPreference = (EditTextPreference)getPreferenceScreen().findPreference("userPass");
これは私のコードです。しかし、preferenceScreen を editTextPreference にキャストできないと言ってクラッシュし続けます。何か案は?
ありがとう。!
ログキャット:
07-19 17:14:23.028: E/AndroidRuntime(7032): FATAL EXCEPTION: main
07-19 17:14:23.028: E/AndroidRuntime(7032): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.contact/com.example.contact.PrefsActivity}: java.lang.ClassCastException: android.preference.PreferenceScreen cannot be cast to android.preference.EditTextPreference