Add http://www. in the text if not Exist

前端 未结 6 624
迷失自我
迷失自我 2021-02-08 21:31

How can I know that some text contain \"http://www.\" I want to show domain in Web View. Domain name is written in TextView but there is no restriction to add prefix. If user di

6条回答
  •  [愿得一人]
    2021-02-08 21:59

    I would just get the text from the TextView and parse it via startsWith(). If this is false, just add it to the text and use setText() to reasign it.

    You might also want to check for other expressions like only "www.". So take a closer look at contains().

提交回复
热议问题