【问题标题】:Find End of line (/n) in EditText android在EditText android中查找行尾(/ n)
【发布时间】:2013-10-09 10:28:28
【问题描述】:

我有一个编辑文本,我想根据按下的按钮在编辑文本的每一行的文本之前附加一些字符。 例如

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

我想如果我了解行尾 (/n),那么我会在每行之前添加五个空格。

知道如何从

获取 /n
EditText scene=(EditText)findViewById(R.id.editText11);

【问题讨论】:

    标签: android android-edittext textview android-textattributes


    【解决方案1】:
    String text = scene.getText().toString();
    String result = "";
    for (String line : text.split("\n"))
    {
       result += "    " + line + "\n";
    }
    scene.setText(result);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-04
      • 1970-01-01
      • 2022-01-10
      • 1970-01-01
      相关资源
      最近更新 更多