Android examples for User Interface:TextView Value
get TextView Value By Line
//package com.java2s; import android.text.Layout; import android.view.ViewTreeObserver; import android.widget.TextView; import java.util.ArrayList; import java.util.List; public class Main { public static List<String> getValueByLine(final TextView tv) { final ArrayList<String> list = new ArrayList<String>(); ViewTreeObserver vo = tv.getViewTreeObserver(); vo.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override//ww w . ja v a 2s.c o m public void onGlobalLayout() { Layout layout = tv.getLayout(); int lines = layout.getLineCount(); String text = layout.getText().toString(); for (int i = 0; i < lines; i++) { int start = layout.getLineStart(i); int end = layout.getLineEnd(i); String temp = text.substring(start, end); list.add(temp); } } }); return list; } }