Sunday, 25 August 2013

Object of main activity in result activity not properly accessing boolean variable?

Object of main activity in result activity not properly accessing boolean variable? References I have a main class that holds two array lists of class objects. Long story short, I\'m calling an activity via startActivityForResult to get a return of the position of a spinner item selection. I have two boolean variables in the main activity that basically tell the application which list is being worked with: booleans listASelected and listBSelected. If listASelected = true, then listBSelected = false and visa-versa. In the result activity I basically generate the spinner this way: MainActivity mainAct = new MainAtivity(); Spinner dropdown = (Spinner)findViewById(R.id.mainMenu); for(int i = 0;i(this, android.R.layout.simple_spinner_item, optionsPickThree); }else{ adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, optionsPickFour); } dropdown.setAdapter(adapter); Then, I use this to do my setResult. Intent output = new Intent(); if(mainAct.pickThreeSelected){ output.putExtra(\"slot\", position); output.putExtra(\"list\", \"PickThree\"); }else{ output.putExtra(\"slot\", position); output.putExtra(\"list\", \"PickFour\"); } setResult(1,output); finish(); } The issue is that nomatter what it always works as if mainAct.pickThreeSelected = true, even if I know it is false because other sections of the app are functioning properly. What I assume is happening is that the class object is accessing the variable\'s initialized values instead of their current values at the time of execution. That, or I\'m an idiot and there\'s a different way to accomplish this. Any help, fellas? Thanks in advance!

No comments:

Post a Comment