Today I am tried to make a calculator, but my clear button is throwing error .
java.lang.IndexOutOfBoundsException: setSpan (5 ... 5) ends beyond length 4
MainActivity.java looks like this,
binding.clearBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
updateText("");
}
});
And My activity_main.xml file looks like this,
<com.google.android.material.button.MaterialButton
android:id="@+id/clearBtn"
android:layout_width="0dp"
android:layout_height="70dp"
android:layout_margin="5dp"
android:layout_weight="1"
android:backgroundTint="#FF9800"
android:text="@string/clear"
android:textSize="24sp"
app:cornerRadius="19dp" />