This is an android text undo redo library. The library is very small, only a Java file.
-
Will TextUndoRedo.java copy to your project.
-
To bind TextUndoRedo and EditText.
TUR = new TextUndoRedo(EditText editText, TextChangeInfo info);- call exeUndo() or exeRedo().
TUR.exeUndo();
TUR.exeRedo();Call exeUndo() before please make sure that canUndo() is true, exeRedo() too.
if(canUndo){
exeUndo();
}
if(canRedo){
exeRedo();
}This is the safest.
or, You can use the interface TextChangeInfo to in time call canUndo() and canRedo().
public interface TextChangeInfo {
void textAction();
}public void textAction() {
btn_undo.setEnabled(TUR.canUndo());
btn_redo.setEnabled(TUR.canRedo());
}but, You need to deal with the issue of the screen direction.(Every time a new TextUndoRedo will create a new Record)
android:configChanges="orientation|keyboardHidden|screenSize"or
android:screenOrientation="portrait"or
android:screenOrientation="landscape"or
......For the above these problems, you can consult sample :)
Name: Arowa_Z
Email: Arowa_Z@qq.com
