title: Duplicate Button Created in Android
body: <p>Although, I have created single copy of button titled:: "Mark as Favourite" in the file <code>fragment_details.xml</code>, I am getting additional duplicate copy of the button in the UI. </p>
  
  <p>Link to git-hub code::  <a href="https://github.com/iamakshit/popular-movies-app/tree/dev-android-stage-2" rel="nofollow noreferrer">https://github.com/iamakshit/popular-movies-app/tree/dev-android-stage-2</a></p>
  
  <p>Snapshot of the UI having duplicate button:
  <a href="https://i.stack.imgur.com/FJUQG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FJUQG.png" alt="enter image description here"></a></p>
  
  <p>Code for fragment_details.xml</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context="akshit.android.com.popularmovies.DetailsActivityFragment"
      tools:showIn="@layout/activity_details"&gt;
  
  
      &lt;ImageView
          android:id="@+id/movie_poster1"
          android:layout_width="match_parent"
          android:layout_height="90dp"
          android:layout_alignParentTop="true"/&gt;
  
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true"
          android:layout_below="@+id/movie_poster1"
          android:orientation="vertical"&gt;
  
          &lt;ImageView
              android:id="@+id/movie_poster"
              android:layout_height="270dp"
              android:layout_width="match_parent"
              android:layout_alignParentTop="true"/&gt;
  
  
          &lt;LinearLayout
              android:orientation="horizontal"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"&gt;
  
              &lt;LinearLayout
                  android:orientation="vertical"
                  android:layout_weight="1"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"&gt;
  
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:paddingTop="10dp"
                      android:id="@+id/movie_title" /&gt;
  
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:id="@+id/user_rating" /&gt;
  
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:id="@+id/release_date" /&gt;
              &lt;/LinearLayout&gt;
  
              &lt;Button
                  android:layout_width="115dp"
                  android:layout_height="wrap_content"
                  android:text="Mark as Favourite"
                  android:id="@+id/fav_button" /&gt;
  
          &lt;/LinearLayout&gt;
  
      &lt;ScrollView
          android:layout_width="fill_parent"
          android:layout_height="0dp"
          android:layout_weight="1"
          &gt;
  
      &lt;LinearLayout
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          &gt;
  
  
      &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:paddingTop="25dp"
              android:id="@+id/plot_summary" /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;/ScrollView&gt;
      &lt;/LinearLayout&gt;
  
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Code of DetailsActivity.java</p>
  
  <pre><code>package akshit.android.com.popularmovies;
  
  import android.content.Intent;
  import android.os.Bundle;
  import android.support.design.widget.FloatingActionButton;
  import android.support.design.widget.Snackbar;
  import android.support.v4.app.Fragment;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.Toolbar;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ImageView;
  import android.widget.TextView;
  
  import com.squareup.picasso.Picasso;
  
  public class DetailsActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_details);
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
  
          if (savedInstanceState == null) {
              Log.i("DetailsActivity", "savedInstanceState is null");
              // During initial setup, plug in the details fragment.
              DetailsActivityFragment details = new DetailsActivityFragment();
              details.setArguments(getIntent().getExtras());
              getSupportFragmentManager().beginTransaction().add(
                      android.R.id.content, details).commit();
          }
  
  
          // For button
  
      }
  
      public static class DetailsActivityFragment extends Fragment {
  
          public static Movie movie;
  
          public DetailsActivityFragment() {
              setHasOptionsMenu(true);
          }
  
          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                   Bundle savedInstanceState) {
              Log.i("DetailsActivity", "onCreateView called");
  
              View rootView = inflater.inflate(R.layout.fragment_details, container, false);
  
  
              // The detail Activity called via intent.  Inspect the intent for forecast data.
              Intent intent = getActivity().getIntent();
  
              if (intent != null &amp;&amp; intent.hasExtra("movie")) {
                  movie = (Movie) intent.getSerializableExtra("movie");
                  Log.i("DetailsActivity", movie.title);
  
                  ((TextView) rootView.findViewById(R.id.movie_title))
                          .setText("Title : "+movie.title);
  
                  ((TextView) rootView.findViewById(R.id.user_rating)).setText("User Rating : "+movie.userRating);
  
                  ((TextView) rootView.findViewById(R.id.plot_summary)).setText("Summary : "+movie.plotSummary);
  
                  ((TextView) rootView.findViewById(R.id.release_date)).setText("Release Date : "+movie.releaseDate);
                  ImageView moviePoster = (ImageView) rootView.findViewById(R.id.movie_poster);
                  Picasso.with(getContext()).load(movie.posterPath).into(moviePoster);
                  moviePoster.setAdjustViewBounds(true);
              }
  
              return rootView;
          }
  
      }
  }
  </code></pre>