Hey guys!! Can someone please tell me whats wrong with this gui script i made.
//Gui Script
var Runnable = java.lang.Runnable;
var PopupWindow = android.widget.PopupWindow;
var Button = android.widget.Button;
var Widget = android.widget;
var LinearLayout = Widget.LinearLayout;
var ViewGroup = android.view.ViewGroup;
var Gravity = android.view.Gravity;
var View = android.view.View;
var AlertDialog = android.app.AlertDialog;
var DialogInterface = android.content.DialogInterface;
var GUI;
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
ctx.runOnUiThread(new Runnable(){
run: function(){
try{
var layout = new LinearLayout(ctx);
var btn = new Button(ctx);
btn.setText("This is a Button");
btn.setOnClickListener(new View.OnClickListener(){
onClick: function(view){
var builder = new AlertDialog.Builder(ctx);
builder.setTitle("This is a Dialog");
builder.setMessage("NICE GUI!!");
builder.setNegativeButton("OK", new DialogInterface.OnClickListener(){
onClick: function(di, view){
di.dismiss();
}
});
var alert = builder.create();
alert.show();
}
});
layout.addView(btn);
GUI = new PopupWindow(layout, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
GUI.showAtLocation(ctx.getWindow().setDecorView(), Gravity.TOP | Gravity.RIGHT, 0, 0);
}catch(e){
print("Error: " + e);
}
}
});
Thanks i feel stupid for a small mistakeI have a qeastion how would i make it to where you press the button and it opens up a menu that i can add buttons to
//Gui Script var Runnable = java.lang.Runnable; var PopupWindow = android.widget.PopupWindow; var Button = android.widget.Button; var Widget = android.widget; var LinearLayout = Widget.LinearLayout; var ViewGroup = android.view.ViewGroup; var Gravity = android.view.Gravity; var View = android.view.View; var AlertDialog = android.app.AlertDialog; var DialogInterface = android.content.DialogInterface; var GUI; var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get(); ctx.runOnUiThread(new Runnable(){ run: function(){ try{ var layout = new LinearLayout(ctx); var btn = new Button(ctx); btn.setText("This is a Button"); btn.setOnClickListener(new View.OnClickListener(){ onClick: function(view){ var builder = new AlertDialog.Builder(ctx); builder.setTitle("This is a Dialog"); builder.setMessage("NICE GUI!!"); builder.setNegativeButton("OK", new DialogInterface.OnClickListener(){ onClick: function(di, view){ di.dismiss(); } }); var alert = builder.create(); alert.show(); } }); layout.addView(btn); GUI = new PopupWindow(layout, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); GUI.showAtLocation(ctx.getWindow().setDecorView(), Gravity.TOP | Gravity.RIGHT, 0, 0); }catch(e){ print("Error: " + e); } } });-
View User Profile
-
View Posts
-
Send Message
Curse PremiumgetDecorView(), not setDecorView()
Create a custom function, create a ScrollView, keep everything together, add all the buttons to a specified layout. Then instead of
do
If you don't want the menu to cover the whole screen, you can divide the width or height.
Want GUI Templates? Done!
https://github.com/BeATz-UnKNoWN/ModPE_Scripts/wiki/ModPE-Script-Templates
P.S. Feel free to follow me so you know when I post "awesome" content and make the MCForums a brighter place (totally).
If you need to contact me you can either shoot a Kik message to beatz_unknown or send an email to [email protected]