Answer the question
In order to leave comments, you need to log in
How to add a button to open the site?
There is a WebViwe object, by default it displays the google.com page. How to add a button so that when you click on it, in the same WebViwe object, the yandex.ru page opens?
Answer the question
In order to leave comments, you need to log in
webView.loadUrl(" https://ya.ru ")
Instead of a button, I would add a menu item to "..." (top-right corner)
https://startandroid.ru/ru/uroki/vse-uroki-spiskom ...
public class MainActivity extends AppCompatActivity {
private WebView webView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button butacc = findViewById(R.id.butacc);
butacc.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
webView.loadUrl("http://ya.ru");
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question