Extract a line from an EditText

后端 未结 3 1104
谎友^
谎友^ 2021-01-12 19:29

How can we extract a line from a multiLine EditText ?

I tried this way, but I know that is not a good practice :

String street1 = \"\";
         


        
3条回答
  •  礼貌的吻别
    2021-01-12 20:04

    Try this:

    String text = streetEt.getText();
    
    String firstLine = text.substring(0,text.indexOf("\n"));
    

提交回复
热议问题