I am trying to set ellipsize of text view. using the following code. I want to add \"view more\" at the end of truncated string after 3 dots. If this would be possible with
It might be late but its the easiest and tested way to handle this issue in recyclerview .
first check the length of textview and set view more if require
if (inventory.getDescription().length()>90) {
inventoryDescription.setText(Html.fromHtml(inventory.getDescription().substring(0,90)+"..."+" View More"));
}
else inventoryDescription.setText(inventory.getDescription());
and in textview click listener
inventoryDescription.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (inventoryDescription.getText().toString().endsWith("View More")) {
inventoryDescription.setText(inventory.getDescription());
}
else {
if (inventory.getDescription().length()>90) {
inventoryDescription.setText(Html.fromHtml(inventory.getDescription().substring(0,90)+"..."+" View More"));
}
else inventoryDescription.setText(inventory.getDescription());
}
}
});