sharedpreferences - Android Custom DialogPreference get key event of EditTextt -


i new android programming. looking solution

i have class extend preferencefragment , create preference extending dialogpreference, set dialog layout custom layout containing edittext.

i want capture key event(up/down/any) on editcustommessage edittext.

how can achieve this?

below part of code

public class settingsfragment extends preferencefragment{  @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     addpreferencesfromresource(r.xml.main_preferences); }  } 

custom preference

public class custom_message extends dialogpreference  {  sharedpreferences prefs; sharedpreferences.editor editor; edittext editcustommessage;  public custom_message(context context, attributeset attrs) {     super(context, attrs);     setpersistent(false);     setdialoglayoutresource(r.layout.custom_message); }  @override protected void onpreparedialogbuilder(alertdialog.builder builder) {     builder.settitle("custom message");     super.onpreparedialogbuilder(builder); }  @override public void onbinddialogview(view view) {      prefs = getsharedpreferences();     editor = prefs.edit();      editcustommessage = (edittext) view.findviewbyid(r.id.editcustommessage);  super.onbinddialogview(view); } } 

main_preferences.xml

<?xml version="1.0" encoding="utf-8"?> <preferencescreen xmlns:android="http://schemas.android.com/apk/res/android">      <preferencecategory android:title="settings">          <in.xxx.custom_message             android:defaultvalue="@string/message_value"             android:key="custom_message"             android:negativebuttontext="@null"             android:positivebuttontext="@null"             android:title="custom message"/>      </preferencecategory>  </preferencescreen> 

custom_message.xml

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dp" android:orientation="vertical">  <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content">  <edittext android:id="@+id/editcustommessage" android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputtype="text|textnosuggestions" android:textappearance="@style/base.textappearance.appcompat.small"/> </linearlayout>   </linearlayout> 

ps: have kept part of code felt necessary. wont able share complete code. thanks


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -