title: Adding Items to ListView from Edittext
body: <p>I have an Actiity where I have a simple Edittext and a button as shwown:</p>
  
  <p><img src="https://i.stack.imgur.com/VwvZp.png" alt="enter image description here"></p>
  
  <p>No I have a MainActivity which contains many fragments as shown:</p>
  
  <p><img src="https://i.stack.imgur.com/2ch0s.png" alt="enter image description here"></p>
  
  <p>This is my Code For passing edittext text to the main activity:</p>
  
  <pre><code>  addlist = (ImageButton) findViewById(R.id.btnaddlist);
    findViewById(R.id.btnaddlist).setOnClickListener(
              new View.OnClickListener() {
                  @Override
                  public void onClick(View arg0) {
                      EditText edit = (EditText) findViewById(R.id.txtlist);
                      Intent i = new Intent(CreateList.this,
                              MainActivity.class);
                      Bundle bundle = new Bundle();
                      String ItemName = edit.getText().toString();
                      // Add your data from getFactualResults method to bundle
                      bundle.putString("ListItemName", ItemName);
                      // Add the bundle to the intent
                      i.putExtras(bundle);
                      startActivity(i);
                  }
              });
  
  }
  </code></pre>
  
  <p>This is my Home fragment:</p>
  
  <pre><code>ListView lv;
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
      lv = (ListView) getView().findViewById(R.id.itemslistView);
      View rootView = inflater.inflate(R.layout.fragment_home, container, false);
      Bundle itemintent = getActivity().getIntent().getExtras();
      String ItemName = itemintent.getString("ListItemName");
  
      if (itemintent.getString("ListItemName").equals("ItemName")) {
          /** Items entered by the user is stored in this ArrayList variable */
          ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();
          list.add(ItemName);
          /** Declaring an ArrayAdapter to set items to ListView */
          ArrayAdapter&lt;String&gt; Listadapter;
          Listadapter = new ArrayAdapter&lt;String&gt;(getActivity().getApplicationContext(),android.R.layout.simple_list_item_1, list);
  
          Listadapter.notifyDataSetChanged();
  
      }
      return rootView;
  }
  </code></pre>
  
  <p>I'm not getting any error in logcat..But its not able to add any text to listView on MainActivity.</p>