1

Given a multi-line EditText, how can I know the line number at cursor position?

4

3 回答 3

0

您的问题存在解决方法。

这个 SO 问题可能会给您一些进一步的见解:如何获取 ContentEditable 区域中的行数和当前插入符号行位置?

于 2012-02-21T18:00:14.517 回答
0

类似 textview.getPaint().measureText(textview.getText().toString()) / textView.getWidth();

这假设光标位于文本的末尾,如果不是,则必须使用子字符串度量。

对不起,我的 iPad 太简洁了

于 2010-10-27T14:55:01.703 回答
-1

Take the text of the control and put it in a string. Loop over the string up to the index of the cursor position and count the number of newlines.

于 2010-10-27T14:50:14.377 回答