Change Custom_Dialog
constructor as :
Context mContext;
protected Custom_Dialog(Context context, int theme) {
super(context, theme);
this.mContext=context; //<<<<<< initialize mContext here
}
and also inside MainActivity
onCreate initialize context
with Activity Context before passing it to Custom_Dialog
constructor as :
//......your code here
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog);
context=MainActivity.this //<<<<< initialize context here
//......your code here