Advertisement
Sketchware

Abrir um link usando edittext

Jan 9th, 2023
1,180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.40 KB | None | 0 0
  1. Button button = (Button) findViewById(R.id.button);
  2. final EditText editText = (EditText) findViewById(R.id.edit_text);
  3. button.setOnClickListener(new View.OnClickListener() {
  4.     @Override
  5.     public void onClick(View v) {
  6.         String url = editText.getText().toString();
  7.         Intent i = new Intent(Intent.ACTION_VIEW);
  8.         i.setData(Uri.parse(url));
  9.         startActivity(i);
  10.     }
  11. });
  12.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement