Install4J variables unavailable till next button - java

I am trying to create a button form component that tests the connection without using the next button because it isn't required before continuing to the next screen. However all the variables that are set in the ui dialog are unavailable till I hit the next button. Anyone have experience of how to either access those variables or force them to be available while on the same dialog without pressing next button.
Variable name: smtp.host
When I read the variable by pressing a button it is empty until I click next -> then back and then I click the button it is assigned and it functions properly.

Run this before you use any of the variables and it will work perfectly.
//Save the variables from the form before continuing
if(!formEnvironment.saveFormComponents())
{
Util.logError(context, "Unable to save form components");
}

Related

Android firebase favorite button changes

I have a list. I shoot data using firebase database. I have a favorite button image on my list. When I click the button, favorites are added to the favorite page. When I click the button, the favorite button image changes. But when I scroll up or down on the page or switch to another page, this changed image returns to its original state. What can I do.
The state of the button is not preserved when moving through activities, because the activity object is re-instantiated each time, so in order to fix it, you just make it a static variable.
private static boolean isCandyPressed = false;
Then in your onclick() of button, set it to true. And thus, handle your logic throughout by cheking this variable.
Hope this solves your problem

Sending value to activity through another

I am working on an update for my Rock Paper Scissors game (I know it's a simple concept and has been done before but still), and the update includes massive changes in layouts and the programming.
So far I have Three working Activities; MainMenu, SinglePlayer, SettingsActivity
The way that things work currently is the user will change a setting (Background, Vibration, etc) inside the SettingsActivity, and when the user hits the Main Menu button it will bundle all values (float backgroundNumber, boolean Vibration) and will send it over to the MainMenu activity. The MainMenu will then unpackage the values and save them, so when the user opens SinglePlayer or any other activity it can send the appropriate values over to that activity.
The issue comes in when the user wants to reset the SinglePlayer score counter...
Here's what works: User presses "Reset Score" inside Settings -> User presses Main Menu button -> User open Single Player (Score resets and everything works fine)
Here's what doesn't work: User presses "Reset Score" inside Settings -> User presses Main Menu button -> User opens a different activity other that Single Player/exits app -> User goes back to main menu -> User goes into Single Player (Score does not reset)
The Main Menu saves all values other than the resetScore boolean (So the score counter doesn't get fed 'resetScore = true;' every time SinglePlayer gets opened).
I'm not trying to advertise but if you are having problems following my description, try following the steps provided above live with the app: https://play.google.com/apps/testing/com.simplegames.chris.rockpaperscissors20
This may be considered a "hack", but this helped me.
After pressing the "Reset Score" button the SinglePlayer Activity is immediately opened to reset the score and then sent back to the Settings Activity. It happens so quickly that it doesn't even look like it left the Settings Activity.
I would remove the question, but who knows... someone else (or me in the future) might need it?

How to make the app wait until something (until variable changes) happens

I created a main class and an adapter for my ListView. In this adapter I created three different types of rows. One of them is a row with EditText. In the adapter class I created a Listener for "Enter" click. After an user clicks "Enter" button, the information entered in EditText saves in a variable.
What I need: I want my app (my main class) wait until this variable changes (from null to something) and after continue doing some actions.
I tried to create a loop, but if ended up with error.
Try to use onEditorDoneListener on the edittext(example is here) when the user presses done button on the keyboard, you can verify the value of the editText and proceed accordingly.
After an user clicks "Enter" button, the information entered in EditText saves in a variable.
It seems that this variable (presumably a String) is only ever changed when the "Enter" button is pressed. So whatever action you want when that String is changed, put them into the onClick method in your Java:
private void enterButtonOnClick(View v) {
// Store the text from EditText into the String variable here
// ...
// Your string variable just changed, so do the desired action...
// Stuff
// and
// things
}
And then in your XML, add this in the button attribute :
android:onClick="enterButtonOnClick"

How to set orientation and copies dynamically with pageDialog?

When I call my pageDialog with printerJob.pageDialog(pageFormat), the dialog box pops up as it should prompting the user to modify the page format of the print job.
Some settings work however some do not such as the orientation radio buttons.
I know I need to use the setOrientation method however, how can I retrieve information from the dialog box such as which radio button did the user click on for portrait or landscape?
Same goes for retrieving the information for how many copies did the user request from the printerJob.printDialog method?
Thank you

returning the dialog from JOptionPane.showOptionDialog

I have created in Java swing an option dialog with the JOptionPane.showOptionDialog method. This dialog includes different buttons, and among those a Cancel button. I would like to attach a listener method to this Cancel button so that once selected, the dialog is disposed.
My question is: how do I "retrieve" (or return) the dialog generated by the JOptionPane.showOptionDialog method?
I will assume you have read "How to Make Dialogs" tutorial from Oracle?
The return value from showOptionDialog() is an int, which indicates which button was chosen. Regardless of pressing OK, cancel or whatever, the window should dispose of itself. If you need more information back from the window then just which button was pressed, look at the other options like showInputDialog().

Categories