Advertisement
peacestorm

HyperLinkButton

Aug 20th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
  2.  
  3. /**
  4.  * function HyperLinkButton(context, text, url)
  5.  * @author peacestorm
  6.  * @since 2016-08-20
  7. */
  8. function HyperLinkButton(context, text, url) {
  9.     this.view = new android.widget.Button(context);
  10.     this.view.setText(text);
  11.     this.view.setOnClickListener(new android.view.View.OnClickListener() {
  12.         onClick: function(viewArg) {
  13.             var uri = android.net.Uri.parse(url);
  14.             var intent = new android.content.Intent(android.content.Intent.ACTION_VIEW, uri);
  15.             context.startActivity(intent);
  16.         }
  17.     });
  18. }
  19.  
  20. HyperLinkButton.prototype = {
  21.     get() {
  22.         return this.view;
  23.     }
  24. }
  25.  
  26. //example
  27. var googleButton = new HyperLinkButton(ctx, "Google", "https://google.com/").get();
  28. //layout.addView(googleButton);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement