in Education by
I have two buttons in MainActivity, the first one opens a custom DialogFragment with some spinners and in the other button it resets the spinners of this DialogFragment. When I click the reset button it calls this method that is in the DialogFragment: public class FilterDialogFragment extends DialogFragment { private View view; // ... @Nullable @Override public View onCreateView(@NotNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { view = inflater.inflate(R.layout.dialog_filters, container, false); // start the spinners and adapters here return view; } public void resetFilters() { if (view != null) { categorySpinner.setSelection(0); productSpinner.setSelection(0); priceSpinner.setSelection(0); } } // some more codes here } My MainActivity: public class MainActivity extends AppCompatActivity { private FilterDialogFragment filterDialog; private Button button_clear; private Button button_filter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button_clear = findViewById(R.id.button_clear); button_filter = findViewById(R.id.button_filter); filterDialog = new FilterDialogFragment(); button_filter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Show the dialog containing filter options filterDialog.show(getSupportFragmentManager(), FilterDialogFragment.TAG); } }); button_clear.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //reset all filters filterDialog.resetFilters(); } }); //some more codes here } //some more methods here } But by clicking the button that opens the DialogFragment, the values of the Spinners remain the same instead of returning the data of position 0 of each spinner. Would anyone know how to solve this? I've tried everything and I can not. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
The simplest way I ended up finding, was to delete the resetFilters method, and instead I did so: button_clear.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //reset all filters filterDialog = new FilterDialogFragment(); } });

Related questions

0 votes
    How can I use Viewpager Adapter Button into MainActivity? I am developing a quiz app and I am comparing ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I'm making a drag and drop game for my A level computing coursework. My drag and drop works fine, but I have 6 ... >= 190 && theButton.Location.X = 42 && theButton.Location.Y...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    In my app I'm using a spinners to let the user select an item from a list. Everything works fine ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    i was trying to work out on my spinner tutorial but it doesnt seem to show the header. can anyone ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 9, 2022 in Education by JackTerrance
0 votes
    i was trying to work out on my spinner tutorial but it doesnt seem to show the header. can anyone ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    In the accompanying diagram, a fair spinner is placed at the centre O of the circle. Diameter AOB and radius OC ... in the region X? Select the correct answer from above options...
asked Nov 25, 2021 in Education by JackTerrance
0 votes
    What does the command git reset –hard HEAD ~3 do? A. Merges the last 3 commits to the master B. Discards ... nothing D. Resets the head to 3 commits before the current commit...
asked Dec 23, 2022 in Technology by JackTerrance
0 votes
    What is the command to reset your index as well as the working directory to the state of your last commit? A. git clean B. git reset C. git revert D. git checkout...
asked Dec 21, 2022 in Technology by JackTerrance
0 votes
    What does the command Git reset –- soft HEAD^ perform? A. Moves commit to one after current head B. Moves commit ... . Moves commit to the first head D. None of the options...
asked Dec 21, 2022 in Education by JackTerrance
0 votes
    I'm using JEE and I created EJB-Singleton. It has as a field LRUMap, which represents cache to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I'm using const embed = new Discord.RichEmbed(); for my embeds. How do I reset the Embed values? ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 29, 2022 in Education by JackTerrance
0 votes
    In my password reset function the user can put in whatever he/she wants. It does not even needs ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    I want to create a request from my application. (iOS and Android - Coded with Xamarin). Explaination: ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I am getting the following error trying to read from a socket. I'm doing a readInt() on that ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 30, 2022 in Education by JackTerrance
0 votes
    I am getting the following error trying to read from a socket. I'm doing a readInt() on that ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 29, 2022 in Education by JackTerrance
...