title: How to pass value from one function to another
body: <p>Hello I want to pass value "valuey" from method veikia() to method
  checkButtonClick(). I`m newby on Java so sorry if this question is already answered, because I do not understand:)</p>
  
  <p>Have a nice day :)</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class ListViewCheckboxesActivity extends Activity {
  
      MyCustomAdapter dataAdapter = null;
      PrekesDBController controller = new PrekesDBController(this);
  
      //private Context mContext;
      ScrollView sv;
      TextView infotext;
      CheckBox check;
      LinearLayout ll;
      Spinner spinner2;
  
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
         // mContext = this;
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main123);
  
         // mContext = this;
  
  
          //Generate list View from ArrayList
          displayListView();
  
          checkButtonClick();
  
          veikia();
  
      }
  
  
    public String veikia() {
        ArrayList&lt;HashMap&lt;String, String&gt;&gt; data2 = controller.getpavadinimas();
        String valuey = "";
        for (int kl = 0; kl &lt; data2.size(); kl++) {
            spinner2 = (Spinner) findViewById(R.id.spinner11);
  
            ScrollView sv = (ScrollView) findViewById(R.id.myscroll123);
            LinearLayout ll = (LinearLayout) findViewById(R.id.mylinearLayout123);
  
            LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View view = inflater.inflate(R.layout.naujasuzsakymailist123, null);
  
  
            ll.addView(view);
  
            //sikna = int kl;
            Spinner jopapa = new Spinner(this);
            jopapa = (Spinner) findViewById(R.id.spinner11);
            jopapa.setId(kl);
  
            List&lt;String&gt; list = new ArrayList&lt;String&gt;();
            list.add("1");
            list.add("2");
            list.add("3");
            list.add("4");
            list.add("5");
            list.add("6");
            list.add("7");
            list.add("8");
            list.add("9");
            list.add("10");
            ArrayAdapter&lt;String&gt; dataAdapter = new ArrayAdapter&lt;String&gt;(this,
                    android.R.layout.simple_spinner_item, list);
            dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            jopapa.setAdapter(dataAdapter);
            valuey = String.valueOf(jopapa.getSelectedItem());
            System.out.println(valuey);
        }
  
  
       return valuey;
    }
  
      public void checkButtonClick() {
  
  
          Button myButton = (Button) findViewById(R.id.findSelected);
          myButton.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
  
                  StringBuffer responseText = new StringBuffer();
                  responseText.append("The following were selected...\n");
  
                  ArrayList&lt;Country&gt; countryList = dataAdapter.countryList;
                  for(int i=0;i&lt;countryList.size();i++){
                      Country country = countryList.get(i);
                      if(country.isSelected()){
                          responseText.append("\n" + country.getName());
                      }
                  }
  
                  Toast.makeText(getApplicationContext(),
                          responseText, Toast.LENGTH_LONG).show();
  
              }
          });
  
      }
  
  }
  </code></pre>