-1

I'm setting up a TextView in my application that users type in a web address, and then a WebView loads it. All of this currently works, and I have it auto filling the TextView with the last used address.

I would like it to prompt the user to put in the address without the https:// by having https:// already there, bold and uneditable. I have seen this done before, but im not even sure how to start on it. any help would be appreciated.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Alex Collette
  • 1,664
  • 13
  • 26
  • Pre-set the "http://" sequence and use an InputFilter to prevent the user to delete the "http://" and to manage the text he enters. – Eselfar May 04 '17 at 15:27

1 Answers1

1

I don't think there is a xml namespace for that, but you can put a TextViewin fron of the EditText and create an illusion like explained here

But the real magic happens when you are reading the EditText which means you put the http:// in front of it.

For example like this

 String url = textView.getText().toString();
 if (!url.startsWith("http")) {
     url = "http://" + url;
  }
Community
  • 1
  • 1
Murat Karagöz
  • 35,401
  • 16
  • 78
  • 107