@Override
public void afterTextChanged(Editable s) {
int lineEndIndex = edtMenu.getText().toString().indexOf("\n");
int firstLineLength;
if (lineEndIndex == -1) {
firstLineLength = edtMenu.getText().toString().length();
Log.e("line First", "Hello" + firstLineLength);
} else {
firstLineLength = lineEndIndex;
}
}
我是从If条件中找到第一行字符但现在我想在空格后找到新行的章程。我怎么能这样做?
答案 0 :(得分:0)
要选择文字的任何部分,请使用Spannable:
String text2 = text + CepVizyon.getPhoneCode() + "\n\n"
+ getText(R.string.currentversion) + CepVizyon.getLicenseText();
Spannable spannable = new SpannableString(text2);
spannable.setSpan(new ForegroundColorSpan(Color.WHITE), text.length(), (text + CepVizyon.getPhoneCode()).length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
myTextView.setText(spannable, TextView.BufferType.SPANNABLE);
您还可以使用html
标记格式化TextView,如下所示:
myTextView.setText(Html.fromHtml(text + "<font color=white>" + CepVizyon.getPhoneCode() + "</font><br><br>"
+ getText(R.string.currentversion) + CepVizyon.getLicenseText()));
或代替TextView
使用WebView
并在HTML文件之前加载准备。
希望它会有所帮助