I have been trying to set a large string (25k+ characters) to a TextView
for a while now but I've been getting a "STRING_TOO_LARGE" output.
I read somewhere that setting the string in run time might help solve that problem, so I modified my code but that didn't seem to help. I also tried setting the resource id directly in setText()
but that didn't do anything as well.
I use the following method in my Activity
to show the terms_dialog
:
private void showTermsPopup() {
Dialog termsDialog = new Dialog(this);
termsDialog.setContentView(R.layout.terms_dialog);
termsDialog.getWindow().setLayout(WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT);
// Cancel the dialog if you touch the background
termsDialog.setCanceledOnTouchOutside(true);
// Add the terms string to the dialog
TextView termsText = termsDialog.findViewById(R.id.termsTextView);
String terms = getResources().getString(R.string.terms);
termsText.setText(terms);
// Show the dialog
termsDialog.show();
}
This is the terms_dialog.xml
file:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:padding="8dp"
android:scrollbarSize="0dp">
<TextView
android:id="@+id/termsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</ScrollView>
</android.support.constraint.ConstraintLayout>
And this is the result I am getting (sensitive info whited out).