在每个新行的开头的EditText

问题描述:

我想获得通过的EditText用户的文本INOUT添加文本,所以我得到了新的文本和检测的新线,但我想在开始时添加文本每一个新的line..How做呢?在每个新行的开头的EditText

Ibold.addTextChangedListener(new TextWatcher(){ 
        @Override 
        public void onTextChanged(CharSequence txt, int start, int before, int count) { 
         if (-1 != bold.indexOf("\n")){ 


          //here I detected new line 


         } 
        } 
+0

你想在每行开头加了什么? –

+0

我想补充一点:*只是一些文字 – user4905906

你可以试试这个:

Ibold.addTextChangedListener(new TextWatcher(){ 
       @Override 
       public void onTextChanged(CharSequence txt, int start, int before, int count) { 
        if (-1 != bold.indexOf("\n")){ 


         //here I detected new line 
         String editTextContent = Ibold.getText().toString(); 
         editTextContent += "ADD YOUR TEXT HERE, IT WILL BE INSERTED AFTER THE LAST LINE BREAK"; 
         Ibold.setText(editTextContent); 


        } 
       } 

参考:Android - Edit Text

+0

应用程序是冻结,keybaord也 – user4905906

+0

我想直接在新行的开头添加文本 – user4905906