Android控件TextLine多行输入,怎么按行获取值
下面内容本人实操可行
1.layout部分
2. 代码中可写
//get lines[startLines,endLines],按行获取TextView的数据
//返回值为对应行中的数据
public static String getDesignationLines(TextView tvBrief, int startLines, int endLines) {
String result = "";
if (startLines > endLines) {
return result;
}
Layout layout = null;
int lineCount = 0;
if (tvBrief.onPreDraw()) {
layout = tvBrief.getLayout();
lineCount = tvBrief.getLineCount();
int a = 1;
}
if (layout == null) {
return result;
}
String text = tvBrief.getText().toString();
String[] strList = text.split("n");
for (int i = startLines; i <= endLines; i++) {
result += strList[i];
}
return result;
}



