title: How to create Yes/NO Alert Dialog in Fragment in Android
body: <p>This is my codes that I commented what I need. I tries some codes but it seems not compatible with Fragment.</p>
  
  <pre><code>public class main extends Fragment {
  
      ImageButton imagebutton;
  
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          View rootView = inflater.inflate(R.layout.main, container, false);
  
          imagebutton = (ImageButton) rootView.findViewById(R.id.im);
  
          imagebutton.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  //Open Yes/No Dialog
  
                  //if Yes do something
              }
          });
  
      }
  }
  </code></pre>