1

I have created custom Preference dialog from answer of this link.

Now I want click event on that button in my ActivityPreferenceScreen activity class. How can i achieve this ?

Community
  • 1
  • 1
Uniruddh
  • 4,427
  • 3
  • 52
  • 86
  • I have mentioned that i am using same class which is in link. I just want to add click event on that button from another class/acitivity. this doesn't incorporate any other specific code. – Uniruddh Jan 08 '14 at 11:25

1 Answers1

1

Add the following attribute in your Activity:

 OnClickListener prefButtonListener = new OnClickListener() {
    public void onClick(View view)
    {
        Log.v("Btn", "Clicked");
    }
};

In the place you instanciate the EditTextPreferenceWithButton class, add this code:

editTextPreferenceWithButton.attachButtonListener(prefButtonListener);

And then, add following in your EditTextPreferenceWithButton class :

    public void attachButtonListener(OnClickListener listener) {
        this.button.setOnClickListener(listener);
    }
}
Uniruddh
  • 4,427
  • 3
  • 52
  • 86
Manitoba
  • 8,522
  • 11
  • 60
  • 122