when I am trying to change text on EditText by calling setText, the function called getLineCount on editText is always 0 after that, why it doesn't change?
Asked
Active
Viewed 27 times
0
-
Please see the answer in this post: https://stackoverflow.com/a/19529765/16234182 – Daniel Weidensdörfer Oct 14 '21 at 17:01
-
2Does this answer your question? [textview.getLineCount always 0 in android](https://stackoverflow.com/questions/3528790/textview-getlinecount-always-0-in-android) – Daniel Weidensdörfer Oct 14 '21 at 17:02
1 Answers
1
If you call getLineCount immediately then it will be always zero because TextView needs some time to draw itself completely.
Try to call this after setText :
editText.post(new Runnable() {
@Override
public void run() {
Log.d("Count", editText.getLineCount().toString());
}
});

Meet Prajapati
- 416
- 5
- 9