0

編集テキストがあります。押されたボタンに応じて、編集テキストの各行のテキストの前にいくつかの文字を追加したいと考えています。例えば

if( fivespacesbutton is pressed )
then
append five spaces on each line the function OnClick(View v) has called.

行末 (/n) について知ったら、各行の前に 5 つのスペースを追加すると思います。

どうすれば/nを取得できますか

EditText scene=(EditText)findViewById(R.id.editText11);
4

1 に答える 1

2
String text = scene.getText().toString();
String result = "";
for (String line : text.split("\n"))
{
   result += "    " + line + "\n";
}
scene.setText(result);
于 2013-10-09T10:34:26.293 に答える