Last active
August 15, 2016 05:47
-
-
Save li2/2de13d883b02f2fdbdc712183c035d29 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by weiyi.li on 2/19/16. | |
* http://li2.me/2016/08/make-a-reusable-ui-in-android-app-development.html | |
*/ | |
public abstract class BasicOperationActivity extends BasicActivity { | |
private ToggleButton mOperationBtn1; | |
private ToggleButton mOperationBtn2; | |
/** Override this method to inflate bottom toolbar layout. */ | |
@Override | |
protected ViewStub inflateOperationToolbar() { | |
ViewStub stub = super.inflateOperationToolbar(); | |
stub.setLayoutResource(R.layout.toolbar_operation); | |
View view = stub.inflate(); | |
mOperationBtn1 = (ToggleButton) view.findViewById(R.id.operation1); | |
mOperationBtn1.setOnClickListener(new DebouncedOnClickListener() { | |
@Override | |
public void onDebouncedClick(View v) { | |
onOperationButton1Clicked(); | |
} | |
}); | |
mOperationBtn2 = (ToggleButton) view.findViewById(R.id.operation2); | |
mOperationBtn2.setOnClickListener(new DebouncedOnClickListener() { | |
@Override | |
public void onDebouncedClick(View v) { | |
onOperationButton2Clicked(); | |
} | |
}); | |
return stub; | |
} | |
/** | |
* Callback when OperationBar's Button_1 & Button_2 clicked. | |
* Subclass must override these two methods to do more things. | |
*/ | |
protected abstract void onOperationButton1Clicked(); | |
protected abstract void onOperationButton2Clicked(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment