public class TextView extends View
This class represents a text view.
Modifier and Type | Method and Description |
---|---|
int |
getCaretLine()
Retrieve the caret current line index.
|
int |
getCaretOffset()
Retrieve the caret current position.
|
java.lang.String |
getLine(int index)
Retrieve a specific line of text in the view.
|
int |
getLineCount()
Get the number of lines of text displayed by the view.
|
int |
getOffsetAtLine(int index)
Get the offset of the first character of the given line.
|
java.lang.String |
getText()
Retrieve the entire text displayed by the view.
|
boolean |
gotoLine(int index)
Position the caret on a specific line
|
void |
setCaretOffset(int offset)
Position the caret at a specific location.
|
void |
setCaretPosition(int lineindex,
int lineoffset)
Position the caret at a specific location.
|
public java.lang.String getText()
public int getLineCount()
Get the number of lines of text displayed by the view.
public java.lang.String getLine(int index)
Retrieve a specific line of text in the view.
index
- 0-based line indexpublic boolean gotoLine(int index)
Position the caret on a specific line
index
- 0-based line indexpublic int getCaretOffset()
Retrieve the caret current position.
public void setCaretOffset(int offset)
Position the caret at a specific location.
offset
- the new caret positionpublic void setCaretPosition(int lineindex, int lineoffset)
Position the caret at a specific location.
Note that this method does not scroll the window to make the caret visible.
A method like gotoLine(int)
can be used in combination with setCaretPosition
to achieve the desired effect.
The getter method ("getCaretPosition") is redundant and not provided in the API. The desired effect can be achieved by using other public methods provided in this class.
lineindex
- the 0-based line index (y coordinate)lineoffset
- the 0-based offset within the line (x coordinate)public int getCaretLine()
Retrieve the caret current line index.
public int getOffsetAtLine(int index)
Get the offset of the first character of the given line.
index
- line index