There is a solution for this.
I had to do this when I was making an application for the terminal, and I used a simple runnable to put the cursor at the end and make it blink.
I made 3 class variables:
private boolean displayCursor; private boolean cursorOn; private String terminalText; private TextView terminal;
terminalText keeps track of the text to be displayed.
A class method has been created that runs runnable for the first time.
private void runCursorThread() { Runnable runnable = new Runnable() { public void run() { if (displayCursor) { if (cursorOn) { terminal.setText(terminalText); } else { terminal.setText(terminalText + '_'); } cursorOn = !cursorOn; } terminal.postDelayed(this, 400); } }; runnable.run(); }
And ran the variables and called runCursorThread() in onCreate()
cursorOn = false; displayCursor = true; runCursorThread();
source share