Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
- /**
- * function HyperLinkButton(context, text, url)
- * @author peacestorm
- * @since 2016-08-20
- */
- function HyperLinkButton(context, text, url) {
- this.view = new android.widget.Button(context);
- this.view.setText(text);
- this.view.setOnClickListener(new android.view.View.OnClickListener() {
- onClick: function(viewArg) {
- var uri = android.net.Uri.parse(url);
- var intent = new android.content.Intent(android.content.Intent.ACTION_VIEW, uri);
- context.startActivity(intent);
- }
- });
- }
- HyperLinkButton.prototype = {
- get() {
- return this.view;
- }
- }
- //example
- var googleButton = new HyperLinkButton(ctx, "Google", "https://google.com/").get();
- //layout.addView(googleButton);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement