Pre-Honeycomb (Android 3), each Activity was registered to handle button clicks via the onClick
tag in a Layout\'s XML:
android:onClick=\"m
Best solution IMHO:
in fragment:
protected void addClick(int id) {
try {
getView().findViewById(id).setOnClickListener(this);
} catch (Exception e) {
e.printStackTrace();
}
}
public void onClick(View v) {
if (v.getId()==R.id.myButton) {
onMyButtonClick(v);
}
}
then in Fragment's onViewStateRestored:
addClick(R.id.myButton);