java - Activity which implements multiple dialog listeners? -



java - Activity which implements multiple dialog listeners? -

i’m getting confused dialog boxes in android , need advice.

everything going well. had numerous dialogs beingness created within mainactivity opened via navi drawer. dialogs created using code this:

private void exportdialog() { layoutinflater inflater = this.getlayoutinflater(); final view formelementsview = inflater.inflate(r.layout.export_data, null, false); alertdialog msgbox = new alertdialog.builder(this) .setview(formelementsview).settitle("export responses") .seticon(android.r.drawable.ic_menu_share) .setpositivebutton("ok", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int which) { // code... } }) .create(); msgbox.show(); }

but started notice problems when device resumed lock screen. switching/pausing/resuming worked fine, locked screen seemed kill activity context , when app resumed dialogs became graphically corrupt , got “activity has leaked window” error message in logs.

so, started again. moved dialogs dialogfragment classes seems ‘proper’ way it. removes error , graphical glitches. great!

but can’t work out how add together more 1 dialog listener mainactivity. i’ve got:

public class mainactivity extends activity implements logindialog.noticedialoglistener{

but can add together more?

until work out how this, i’ve altered many of mainactivity methods , moved them relevant dialog classes, works fine seems rather linear approach. nice if mainactivity deed upon each dialog response.

as can guess, i’m not professional developer i’m getting rather lost!

update:

ok, seems original problem of graphic glitches , "leaked window" messages because dialog boxes not beingness dismissed correctly. adding next seems have improved matters:

@override public void ondestroy() { super.ondestroy(); if (dialogbox1!=null){ dialogbox1.dismiss(); } dialogbox1= null; if (dialogbox2!=null){ dialogbox2.dismiss(); } dialogbox2= null; if (dialogbox3!=null){ dialogbox3.dismiss(); } dialogbox3= null; ...

use inner classes implements logindialog.noticedialoglistener

java android dialog

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -