title: how to get data from setOnClickListener and pass it to CountdownTimer
body: <p>How can I get the computations I did on my onclick and use that data as a parameter for my CountDownTimer? I made a simple conversion of inputs to milliseconds in my onclick method and I want to pass it to my actual timer to change the duration. as far as I know passing parameter to a CountDownTimer works like this:</p>
  
  <pre><code>  private CountDownTimer countDownTimer = new CountDownTimer(duration_variable, 1000) {
          @Override
          public void onTick(long duration_variable) {
              long millis= duration_variable;
              String hms= String.format("%02d:%02d",
  
                      TimeUnit.MILLISECONDS.toHours(millis),
                      TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis))
                      //TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis))
              );
              timer.setText(hms);
          }
  
          @Override
          public void onFinish() {
              Toast.makeText(getActivity(), "timer stopped",Toast.LENGTH_SHORT).show();
          }
      };
  }
  </code></pre>
  
  <p>The only problem now is getting the data from my onclick method.</p>
  
  <p>Here's the class that contains the onclick method:</p>
  
  <pre><code>public class page2 extends Fragment {
      private static final String TAG =   "page2";
  
      private Button btntest;
      private TextView timer,tv2;
      private TextView tv;
      private Spinner spinner, spinner2;
      public int hours, mins, duration;
      @Nullable
      @Override
      public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
          View view = inflater.inflate(R.layout.page2_fragment,container,false);
  
          btntest = (Button) view.findViewById(R.id.button2);
          timer = (TextView) view.findViewById(R.id.Timer);
          tv2 = (TextView) view.findViewById(R.id.tv2);
          tv = (TextView) view.findViewById(R.id.textView3);
  
          //setting up spinners
          spinner = (Spinner) view.findViewById(R.id.spinner1);
          String [] values = {"00","01","02","03","04","05","06"};
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this.getActivity(), android.R.layout.simple_spinner_item, values);
          adapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
          spinner.setAdapter(adapter);
          spinner2 = (Spinner) view.findViewById(R.id.spinner2);
          String [] values2 = {"00","10","20","30","40","50","60"};
          ArrayAdapter&lt;String&gt; adapter2 = new ArrayAdapter&lt;String&gt;(this.getActivity(), android.R.layout.simple_spinner_item, values2);
          adapter2.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
          spinner2.setAdapter(adapter2);
  
          btntest.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
  
                  String spin=spinner.getSelectedItem().toString();
                  hours = Integer.parseInt(spin);
                  hours = hours*3600000;
                  String spin2=spinner2.getSelectedItem().toString();
                  mins = Integer.parseInt(spin2);
                  mins = mins*60000;
                  duration = hours+mins;
                  tv2.setText(String.valueOf(duration));
                  countDownTimer.start();
              }
          });
          return view;
      }
  </code></pre>