I'm new to programming as of a year now and I'm working on an Browser app. My goal is to have a user, enter an URL in a TextEdit field and it goes to a website or they just type in a word and it performs a google search.
I know I must us an if else statment to do this. my problem is how exactly to go about doing so. originally ive tried
button.setOnClickListener(new View.OnClickListener() {
private Object URL;
@Override
public void onClick(View view) {
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
if (webView == (WebView) URL); {
webView.loadUrl(String.valueOf(editText.getText()));
editText.setText("");
}
if (webView == editText.setText(""); {
webView.loadUrl("https://www.google.com/#q=" + editText.getText());
}
}
});
im getting an ')' expected error thats all thats showing but im sure theres more to this it does not feel right, hopefully you all can help me.
Aucun commentaire:
Enregistrer un commentaire