2
Here’s what I’m trying to do
So the user doesn’t need to type https://
I’m trying to make sure that when the text of EditText
start with www.
will automatically insert the https://
I tried to:
if (!s_url.startsWith("www.")) {
myWebView.loadUrl("http://"+s_url);
}
But to no avail.
What am I doing wrong?
Code:
final String s_url = editText_url.getText().toString();
final WebView myWebView = (WebView) findViewById(R.id.webview);
final EditText editText_url = (EditText) findViewById(R.id.edittext_url);
//IME Action
editText_url.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
boolean handled = true;
if (actionId == EditorInfo.IME_ACTION_GO) {
myWebView.loadUrl(editText_url.getText().toString());
if (!s_url.startsWith("www.")) {
myWebView.loadUrl("http://"+s_url);
}
return true;
}
return true;
}
});
You can edit your server’s virtual host?
– Rodrigo Rigotti