我能将set-listener那一行分成小行么?
这是我现在的代码:
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; } });
我想要像这样的:
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; }
守着星空守着你
函数式编程
相关分类