В моем приложении для Android я показываю диалоговое окно, содержащее edittext
. Это DialogBox отображается с помощью PreferenceCategory
.My xml
файл выглядитПолучить событие в диалоговом окне (ОК, Отмена) нажата (Android)
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory android:title="@string/security_setting_edittext_hint" >
<EditTextPreference
android:dialogTitle="@string/security_setting_button"
android:key="set_password_preference"
android:summary="@string/set_password_summary"
android:title="@string/security_setting_button"
android:inputType="number"
android:icon="@drawable/lock"
/>
</PreferenceCategory>
</PreferenceScreen>
Мой файл Java выглядит
public class Settings extends PreferenceActivity {
Dialog setPasswordDialog;
EditText setPassword;
EditTextPreference editPreference;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setTitle("Settings");
addPreferencesFromResource(R.xml.preference_authentication);
editPreference=(EditTextPreference) findPreference("set_password_preference");
}
Там не проблема при отображении dialog
, но теперь я хочу Тхо получить событие, когда Ok и Отмена нажмите кнопку из диалогового окна, чтобы что-то сделать. Пожалуйста, предоставьте мне решение.
Как вы хотите использовать диалоговое окно, отображаемое с помощью PreferenceCategory, вам нужно будет создать пользовательскую EditTextPreference, как показано в ответе @appsroxcom. – appsroxcom