Can someone tell me why cannot i call setOnClickListener method on my buton in custom dialog method? Is there a possible way to handle clicks in this kind of dialog? Here's the code:
private Dialog wifiDialog() { final Dialog dialog = new Dialog(activity); dialog.setContentView(R.layout.wifi_dialog); dialog.setTitle("Upload"); Button no = (Button) findViewById(R.id.button_wifi_No); Button yes = (Button) findViewById(R.id.button_wifi_Yes); no.setOnClickListener(new OnClickListener() { // runtimeException @Override public void onClick(View v) { wifiDialog().dismiss(); } }); return dialog; } Thanks in advance