title: how can i access the button id in activity from fragment
body: <p>How to access button id in an activity.</p>
  
  <p>Activity</p>
  
  <pre><code>  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.fragment_meter);
      if (Build.VERSION.SDK_INT &gt;= 23) {
          checkLocationPermission();
      }
  
  
  
   FragmentManager fragmentManager =  getSupportFragmentManager();
      FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
      Fragment map = new Map();
      fragmentTransaction.add(R.id.fragment_container, map);
      fragmentTransaction.commit();
  
   ...
  }
  </code></pre>
  
  <p>Fragment</p>
  
  <pre><code>@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
  
  
  
  
    if (view == null) {
          view = inflater.inflate(R.layout.fragment_map, container, false);
  
          Button button = (Button)getActivity().findViewById(R.id.btnStop);
  
      }
  </code></pre>
  
  <p>How to implement setOnClickListener method of btnStop in my code fragment?</p>