TextView with permenant http://

40 Views Asked by At

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.

1

There are 1 best solutions below

1
Murat Karagöz On BEST ANSWER

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;
  }