Android how to pass a variable to another java file -
in reminder1.java have int hourofday2 , int minute2 variables. these equals hourofday , minute variable of timepickerdialog. in myfile.java want examine value of these variables. how that?
one thing i've seen posted here on few times, , i've used global variables, extended application class, so:
public class globalvars extends application { private static int hourofday2; private static int minute2; public static int gethourofday() { return hourofday2; } public static int getminute() { return minute2; } public static void sethourofday(int hour) { hourofday2 = hour; } public static void setminute(int minute) { minute2 = minute; } }
add application tag in manifest, so:
<application android:name=".globalvars" />
then, in main class's oncreate, or wherever necessary, call globalvars.setminute(int)
initialize them, can access them same way in other class, int x = globalvars.getminute()
.
Comments
Post a Comment