1

I am using a TextView for log purposes inside an Android app, and if it gets too long the app becomes unstable. Is it possible to set a max limit so TextView removes old text after it gets to a certain size? If not I can set the app to automatically clear the text once a day. If I want to clear the text manually, do I call TextView.clearComposingText(); ?

david
  • 997
  • 3
  • 14
  • 34

1 Answers1

1
 <TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:maxLength="100"/>

Set the maximum length of the textview to a limit number and also check when to clear the textview. Write the following function in Activity and call it on onCreate.

private void checklength(){
   if(textview.getText().length()==100){
       textview.setText("");
   }
}

Hope it helps.

Dipin P J
  • 58
  • 8