title: Making a button to show a toast and sending a data to another activity
body: <p>I am trying to send data from one activity to another and also to show toast when the button is pressed I am trying to accomplish both at same time.The id of the button I have assigned is <code>add_to_cart</code> and I tried this code below and i didnt work </p>
  
  <pre><code>Button customToastButton = (Button) this.findViewById(R.id.add_to_cart);
      customToastButton.setOnClickListener(new View.OnClickListener() {
  
          public void onClick(View v) {
  
              //get the LayoutInflater and inflate the custom_toast layout
              LayoutInflater inflater = getLayoutInflater();
              View layout = inflater.inflate(R.layout.cart_toast, (ViewGroup)
                      findViewById(R.id.toast_layout_root));
  
              //get the TextView from the custom_toast layout
              TextView text = (TextView) layout.findViewById(R.id.toastText);
              text.setText("Item as been added to cart");
  
              //create the toast object, set display duration,
              //set the view as layout that's inflated above and then call show()
              Toast t = new Toast(getApplicationContext());
              t.setDuration(Toast.LENGTH_SHORT);
              t.setView(layout);
              t.show();
  
  
              Bundle intent = getIntent().getExtras();
              if (intent != null) {
                  firstname= intent.getString("Gladwin");
                  secondname= intent.getString("james");
              }
  
  
  
          }
  
      });
  </code></pre>
  
  <p>The toast part works fine but not the data sending part and I tried Implementing  separately this code to send the data but was not responsive and below is the code I am using to receive the data sent</p>
  
  <pre><code>private String firstname;
  private String secondname;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_cart);
  
  
      TextView txtFirst=(TextView)findViewById(R.id.text1);
      txtFirst.setText(firstname);
      TextView txtSecond=(TextView)findViewById(R.id.textview1);
      txtSecond.setText(secondname);
  </code></pre>
  
  <p>and this is the XML part of the receiving end</p>
  
  <pre><code>&lt;TextView
      android:id="@+id/text1"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentTop="true"
      android:layout_marginLeft="15dp"
      android:layout_marginTop="10dp"
      android:text=""
      android:textSize="20sp" /&gt;
  &lt;TextView
      android:layout_below="@+id/text1"
      android:id="@+id/textview1"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginLeft="15dp"
      android:layout_marginTop="10dp"
      android:text=""
      android:textSize="20sp" /&gt;
  </code></pre>
  
  <p>I know there a are lot of newbie mistakes sorry for that tho</p>