मैं इस संवाद में एक दृश्य दिखाने के लिए एक कस्टम संवाद करने की कोशिश कर रहा हूं।एक कस्टम संवाद खारिज करें?
//Getting the layout
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.custom_dialog_simple,
(ViewGroup) findViewById(R.id.rlDialogSimple));
//Change Text and on click
TextView tvDialogSimple = (TextView) layout.findViewById(R.id.tvDialogSimple);
tvDialogSimple.setText(R.string.avisoComprobar);
Button btDialogSimple = (Button) layout.findViewById(R.id.btDialogSimple);
btDialogSimple.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//Do some stuff
//Here i want to close the dialog
}
});
AlertDialog.Builder builder = new AlertDialog.Builder(AcPanelEditor.this);
builder.setView(layout);
AlertDialog alert = builder.create();
alert.show();
तो, मैं btDialogSimple की onClick में संवाद निरस्त करना चाहते हैं: इस बिल्डर कोड है। यह मेरे द्वारा कैसे हो सकता है? मुझे नहीं पता कि ऑनक्लिकलिस्टर के अंदर से बर्खास्तगी विधि को कैसे कॉल करें।
मेरे बटन में एक कस्टम लेआउट है, इसलिए मैं builder.setPositiveButton नहीं बनाना चाहता हूं।
कोई विचार?
के अंदर कॉल करें महान प्रश्न! यह बिल्कुल सही तरीका है * लगता है * यह काम करना चाहिए। लेकिन निश्चित रूप से, यह नहीं है - यह बस आसान हो जाएगा! (एंड्रॉइड वे नहीं)। –