title: Updating a listView after button click - android
body: <p>I am trying to put a list under 2 editTexts and 2 buttons. I am wondering how I can have the list be populated with strings after a button press. </p>
  
  <p>Right now, I have an ArrayList and when the button is hit, it calls a method that uses data from the editTexts and adds values to the ArrayList. When I run it, it force closes. All I want to do is update the list with new values. Any idea are greatly appreciated.</p>
  
  <p>Here is my code simplified a lot. This is where I am. </p>
  
  <pre><code>    public class test extends ListActivity{
  
      EditText currentText;   
      int current;
      EditText goalText;
      int goal;
              int[] xpTable = {1,200,30000,400000,500000};
  
      static ArrayList&lt;String&gt; objs = new ArrayList&lt;String&gt;();
  
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);         
  
  
          Button calc = (Button) findViewById(R.id.calc);
          calc.setOnClickListener(new View.OnClickListener() {
              public void onClick(View view) {
                  myMethod();
              }
  
          });
  
      }
  
      public void myMethod(){
  
          currentText = (EditText)this.findViewById(R.id.xp);
          goalText = (EditText)this.findViewById(R.id.level);
          current = Integer.parseInt(currentText.getText().toString());
          goal = Integer.parseInt(goalText.getText().toString());
          int needed = xpTable[goal] - current;
  
          double laps = 0;
          double value1= 50.5;
          double value2= 100;
  
  
  
          laps = (needed/value1);
          if (laps % 1 != 0)
              laps = (laps - laps % 1) + 1;
          objs.add((int)laps + " value1");
  
          laps = (needed/value2);
          if (laps % 1 != 0)
              laps = (laps - laps % 1) + 1;
          objs.add((int)laps + " value2");
  
  
          setListAdapter(new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, objs));
      }
  }
  </code></pre>
  
  <p>Sorry for all my simple questions, This community is great for help.</p>