title: showDialog in button Listview adapter
body: <p>i have a listView like <a href="https://stackoverflow.com/questions/30092158/set-button-onclick-in-listview-android/30092841#30092841">THIS</a></p>
  
  <p><img src="https://i.stack.imgur.com/iBS2E.png" alt="enter image description here"></p>
  
  <p>i want when i press the delete. it show a dialog like this image</p>
  
  <p><img src="https://i.stack.imgur.com/BEFdl.png" alt="enter image description here"></p>
  
  <p>so when i press YES. it will remove from list.</p>
  
  <p>here's my code..</p>
  
  <pre><code>public class customadapter extends BaseAdapter{ 
  
  ArrayList&lt;HashMap&lt;String, String&gt;&gt; oslist;
  Context context;
  private Button btnDelete;
  private Button btnEdit;
  AlertDialog.Builder alertDialogBuilder;
  
  public customadapter(ArrayList&lt;HashMap&lt;String, String&gt;&gt; oslist,Context context) {  
      System.out.println("skdjfhksdfjskfjhsdkjfh");
      this.context = context;
      this.oslist = oslist;
  
  }
  
  @Override
  public int getCount() {
      // TODO Auto-generated method stub      
      return oslist.size();
  }
  
  @Override
  public Object getItem(int position) {
      // TODO Auto-generated method stub
      return oslist.get(position);
  }
  
  @Override
  public long getItemId(int position) {
      // TODO Auto-generated method stub
      return position;
  }
  
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
      System.out.println("oslist oslist = "+oslist);
      System.out.println("oslist 1 = "+oslist);
      System.out.println("oslist size = "+oslist.size());
      System.out.println("oslist oslist = "+oslist.getClass());
      System.out.println("position = "+position);
      System.out.println("convertView = "+convertView);
      System.out.println("parent = "+parent);
  
      System.out.println("position =  "+position);
  
  
  
  
  
      LayoutInflater lif = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      convertView = lif.inflate(R.layout.listitem, null);
  
      TextView id = (TextView) convertView.findViewById(R.id.varId);  
      TextView noNota = (TextView) convertView.findViewById(R.id.varNoNota);
      TextView senderName = (TextView) convertView.findViewById(R.id.varSenderName);
      TextView totalAmount = (TextView) convertView.findViewById(R.id.varTotalAmount);
  
      id.setText(oslist.get(position).get("id"));
      noNota.setText(oslist.get(position).get("noNota"));
      senderName.setText(oslist.get(position).get("senderName"));
      totalAmount.setText(oslist.get(position).get("totalAmount"));   
  
      Button btnEdit = (Button) convertView.findViewById(R.id.btnEdit);
      Button btnDelete = (Button) convertView.findViewById(R.id.btnDelete);
      btnEdit.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View v) {
  
              Toast.makeText(context, "Edit ditekan!", Toast.LENGTH_LONG).show();
              //I want show YES NO dialog here.           
          }
      });
  
      btnDelete.setOnClickListener(new OnClickListener() {                
          @Override
          public void onClick(View v) {
              //I want show YES NO dialog here
          }
      });   
  
      return convertView;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>how can i do to create a dialog like that..i tried this code</p>
  
  <pre><code>final Dialog dialog = new Dialog(context);
                  dialog.setContentView(R.layout.custom);
                  dialog.setTitle("Title...");
  
                  // set the custom dialog components - text, image and button
                  TextView text = (TextView) dialog.findViewById(R.id.text);
                  text.setText("Android custom dialog example!");
                  ImageView image = (ImageView) dialog.findViewById(R.id.image);
                  image.setImageResource(R.drawable.ic_launcher); //line 115
  
                  Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK);
                  // if button is clicked, close the custom dialog
                  dialogButton.setOnClickListener(new OnClickListener() {
                      @Override
                      public void onClick(View v) {
                          dialog.dismiss();
                      }
                  });
  
                  dialog.show();
  </code></pre>
  
  <p>but itsnt success.</p>
  
  <p>i got this error</p>
  
  <p><img src="https://i.stack.imgur.com/CPorB.png" alt="enter image description here"></p>