title: combining 2 activities together
body: <p>ok so I'm making an app where I use an edit text to write anything and when I press a button it adds whatever I wrote in the edit to a listView, and it works, but I want the List to be in a different activity than the button and edit text, so I moved it without changing the code.can anyone figure this out,</p>
  
  <p>BTW all the variables are public.</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
      public ArrayList&lt;String&gt; arrayList2;
      public ArrayAdapter&lt;String&gt; adapter,adapter2;
      public EditText editText,editText2;
      public ArrayList&lt;String&gt; itemList,itemList2;
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          String[] items = {};
          itemList = new ArrayList&lt;String&gt;(Arrays.asList(items));
          adapter = new ArrayAdapter&lt;String&gt;(this, R.layout.activity_list_layout,R.id.txtItem,itemList);
          ListView listV = (ListView)findViewById(R.id.list_layout);
          listV.setAdapter(adapter);
          editText = (EditText)findViewById(R.id.thingadd);
          Button btAdd = (Button)findViewById(R.id.add);
  
          String[] age = {};
          arrayList2 = new ArrayList&lt;String&gt;(Arrays.asList(age));
          itemList2 = new ArrayList&lt;String&gt;(Arrays.asList(age));
          adapter2 = new ArrayAdapter&lt;String&gt;(this, R.layout.activity_list__layout2,R.id.txtage,itemList2);
          ListView listV2 = (ListView)findViewById(R.id.Age);
          listV2.setAdapter(adapter2);
          editText2 = (EditText)findViewById(R.id.agetxt);
  
          btAdd.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  String newItem=editText.getText().toString();
                  String newItem2=editText2.getText().toString();
  
                  itemList.add(newItem);
                  itemList2.add(newItem2);
  
                  adapter.notifyDataSetChanged();
                  adapter2.notifyDataSetChanged();
              }
          });
      }
  }
  </code></pre>