How do I insert this subclass into my code?

Posted by BamsBamx on Stack Overflow See other posts from Stack Overflow or by BamsBamx
Published on 2012-06-21T14:45:30Z Indexed on 2012/06/21 15:16 UTC
Read the original article Hit count: 205

Filed under:
|
|

This is a very noob question so I hope you can help me with this...

This is my built code:

 public class PantallaOpciones extends PreferenceActivity {

   private SharedPreferences preferences; 

   @Override
   public void onCreate(Bundle savedInstanceState) {

      preferences = PreferenceManager.getDefaultSharedPreferences(this);
      findPreference("speechkeycode").setOnPreferenceClickListener(keycodedialog);

      Preference.OnPreferenceClickListener keycodedialog = new Preference.OnPreferenceClickListener(){
         public boolean onPreferenceClick(Preference preference){
         keycodedialog();
         return false;   }};
}


 private void keycodedialog(){
    final Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.keycodedialog);
    dialog.setTitle("Speech keycode");
    final TextView keypresstext = (TextView) findViewById(R.id.keypresstext);

    Button savekeycode = (Button) dialog.findViewById(R.id.btnsavekeycode);
    savekeycode.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
    Button resetkeycode = (Button) dialog.findViewById(R.id.btnresetvalue);
    resetkeycode.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                dialog.dismiss();
            }
        });

    dialog.show();
}

Okay, now I want to add this code to dialog:

public boolean onKeyDown(int keyCode, KeyEvent event) {
    //SOME STUFF
    return super.onKeyDown(keyCode, event);
}

So I want to listen to a keypress when dialog is opened and show the keycode of hardware press by using textview.settext()... The question is: how do I insert public boolean onKeyDown into the dialog???

Thanks in advance!! :)

© Stack Overflow or respective owner

Related posts about java

Related posts about android