In my Android application I am displaying the dialogbox which contains edittext
. This dialogbox is displayed using PreferenceCategory
.My xml
file looks like
<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>
My Java file looks like
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");
}
There is no issue in displaying the dialog
but now i want tho get event when Ok and Cancel button from dialog box is pressed to do something.
Please provide me solution.
You will need to create your custom edit text preference as follows.
Then use it in xml file as follows:
where com.package should be replaced by the actual package in your project where you create MyEditTextPreference
If I get your question correctly, you want to handle the "Ok" and "Cancel" event and then perform some action based on the response.