Hello my friends,
I try to implement this code but with no luck.
Java Code:
B4A code:
p.s. I am not very interested in be clickable and expandable. I just want to set how many lines will be for ellipsize and the text at the end of line "..."
I try to implement this code but with no luck.
Java Code:
B4X:
public void makeTextViewResizable(final TextView tv, final int maxLine, final String expandText) {
if (tv.getTag() == null) {
tv.setTag(tv.getText());
}
ViewTreeObserver vto = tv.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@SuppressWarnings("deprecation")
@Override
public void onGlobalLayout() {
ViewTreeObserver obs = tv.getViewTreeObserver();
obs.removeGlobalOnLayoutListener(this);
if (maxLine <= 0) {
int lineEndIndex = tv.getLayout().getLineEnd(0);
String text = tv.getText().subSequence(0, lineEndIndex - expandText.length() + 1) + " " + expandText;
tv.setText(text);
} else if (tv.getLineCount() >= maxLine) {
int lineEndIndex = tv.getLayout().getLineEnd(maxLine - 1);
String text = tv.getText().subSequence(0, lineEndIndex - expandText.length() + 1) + " " + expandText;
tv.setText(text);
}
}
});
}
B4A code:
B4X:
Private nativeMe As JavaObject
nativeMe = Me
nativeMe.RunMethod("makeTextViewResizable", Array As Object(lblNotification,1,"Read more..."))
p.s. I am not very interested in be clickable and expandable. I just want to set how many lines will be for ellipsize and the text at the end of line "..."