Separate a java listener to its own function?
<p>Can I break the set-listener line into smaller pieces?</p>

<p>Here is the code I have:</p>

<pre><code>protected void onCreate(Bundle savedInstanceState) {
   Preference button = (Preference)getPreferenceManager().findPreference("exitlink");      

      button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
             @Override
             public boolean onPreferenceClick(Preference arg0) {
                finish();   
                return true;
             }
        });     
</code></pre>

<p>I would like this to look something like:</p>

<pre><code>protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Preference button = (Preference)getPreferenceManager().findPreference("exitlink");      
    if(button != null) {
         button.setOnPreferenceClickListener(onPreferenceClick);
    }        
}

public boolean onPreferenceClick(Preference arg0) {
    finish();   
    return true;
}
</code></pre>
