For my list view am using custom Adapter which extends ArrayAdapter. in listiview i have 2 buttons one of the buttons as Custom AlertDialogBox. Ex: Activity parentActivity; Constructor for Adapter `
public CustomAdapter(ArrayList<Contact> data, Activity parentActivity,Context context) {
super(context,R.layout.listdummy,data);
this.mContext = context;
this.parentActivity = parentActivity;
}
` calling Adapter from MainActivty
adapter = new CustomAdapter(dataModels,MainActivity.this,this);
_x000D_
now write ur alertdialog inside ur button which is in the Adapter class
viewHolder.update.setOnClickListener(new View.OnClickListener() {_x000D_
@Override_x000D_
public void onClick(final View view) {_x000D_
_x000D_
_x000D_
AlertDialog.Builder alertDialog = new AlertDialog.Builder(parentActivity);_x000D_
alertDialog.setTitle("Updating");_x000D_
alertDialog.setCancelable(false);_x000D_
_x000D_
LayoutInflater layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);_x000D_
@SuppressLint("InflateParams") final View view1 = layoutInflater.inflate(R.layout.dialog,null);_x000D_
alertDialog.setView(view1);_x000D_
alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {_x000D_
@Override_x000D_
public void onClick(DialogInterface dialogInterface, int i) {_x000D_
dialogInterface.cancel();_x000D_
}_x000D_
});_x000D_
alertDialog.setPositiveButton("Update", new DialogInterface.OnClickListener() {_x000D_
@Override_x000D_
public void onClick(DialogInterface dialogInterface, int i) {_x000D_
_x000D_
//ur logic_x000D_
}_x000D_
}_x000D_
});_x000D_
alertDialog.create().show();_x000D_
_x000D_
}_x000D_
});
_x000D_