I have to generate a layout according to the information the app gets from the network. Sometimes, it can have email adresses that I might need to truncate if they are too long for the space available.
My problem is that I can truncate them and fit them to the size I need, but they won't be visible until I click on them.. :S
Here's my code for my email textviews:
TextView noneText = new TextView(getActivity());
noneText.setWidth(width);
noneText.setSingleLine(true);
noneText.setTextSize(cell.getCSS().getTextSize() + 4);
noneText.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
noneText.setText(cell.getText());
if(cell.getType() == AutoActionElement.AutoGridActionElementType.EML){
// Email
noneText.setAutoLinkMask(Linkify.EMAIL_ADDRESSES);
noneText.setMovementMethod(LinkMovementMethod.getInstance());
}
if (displayedAutogrid.getColumn(cellNo).isTruncated()) {
noneText.setEllipsize(TextUtils.TruncateAt.END);
noneText.setLines(1);
}
noneText.setGravity(Gravity.CENTER_VERTICAL | cell.getCSS().getGravity());
noneText.setPadding(noneText.getPaddingLeft(), padding, noneText.getPaddingRight(), padding);
layout.addView(noneText);
Thanks
Edit It works fine with phone numbers. They are truncated and display but not the emails....
Edit For now, I will change my method and simply not make the text clickable if truncated because there is a detailed view of the information where the email is stocked available. By viewing the detailed view, the email will show completely. Clicking on the layout containing some information (and the truncated email) will lead to the detailed view. I'm still looking for an answer, not to use in my app but just for my Android knowledge!