as3 Android native multi-choice (single) dialog for adobe Air

Android Native Extension Dialog for Air
The more I work on extensions the more I see how chaotic they are.
But never mind..
New classes in my as3NativeAlert.
Now a class NativeMultiChoiceDialog has the ability to show a native android popup multi-choice(or single) dialog inside Adobe Air project.

Usage:

private var NativeListDialog;
private var choces:Vector.<String>;
private var buttons:Vector.<String>;
private var checkedItems:Vector.<Boolean>;
private var selectedIndex:int = -1;

protected function view1_viewActivateHandler(event:ViewNavigatorEvent):void
{
      choces = new Vector.<String>();
//the text of the items to be displayed in the list.
      choces.push("one",'two","three","four");
      checkedItems = new Vector.<Boolean>();  
// specifies which items are checked. It should be null in which case no items are checked. If non null it must be exactly the same length as the array of items.
      checkedItems.push(true,false,false,true);
      buttons = new Vector.<String>();
//the labels for the buttons. It should be null in which case there will be only one button "OK". If non null max length 3 buttons
      buttons.push("OK","Settings","Cancle");
}
protected function openMultiChoiceDialog(event:MouseEvent):void
{
      multChDialog = new NativeListDialog();
      multChDialog.theme = NativeListDialog.THEME_HOLO_DARK;
      multChDialog.addEventListener(NativeDialogEvent.CANCLED,closeNativeDialogHandler);
      multChDialog.addEventListener(NativeDialogEvent.OPENED,traceEvent);
      multChDialog.addEventListener(NativeDialogEvent.CLOSED,closeNativeDialogHandler);
      multChDialog.addEventListener(NativeExtensionErrorEvent.ERROR,onError);
      multChDialog.addEventListener(NativeDialogListEvent.LIST_CHANGE,onListChange);
      multChDialog.title ="Some Title";
      multChDialog.cancleble = true;
      multChDialog.showMultiChoice(choces,checkedItems,buttons);
}
public function openSingleChoiceDialog(event:MouseEvent):void
{
	singleChDialog = new NativeListDialog();
	singleChDialog.theme = ThemeSelector.selectedItem.data;
	singleChDialog.addEventListener(NativeDialogEvent.CANCLED,closeNativeDialogHandler);
	singleChDialog.addEventListener(NativeDialogEvent.OPENED,traceEvent);
	singleChDialog.addEventListener(NativeDialogEvent.CLOSED,closeNativeDialogHandler);
	singleChDialog.addEventListener(LogEvent.LOG_EVENT,traceEvent);
	singleChDialog.addEventListener(NativeExtensionErrorEvent.ERROR,onError);
	singleChDialog.addEventListener(NativeDialogListEvent.LIST_CHANGE,onListChange);
	singleChDialog.cancleble = true;
	singleChDialog.showSingleChoice(choces,selectedIndex,buttons,titleInput.text);
}
public function closeNativeDialogHandler(event:NativeDialogEvent):void
{
	var dialog:NativeListDialog = (event.target  as NativeListDialog);
	dialog.removeEventListener(NativeDialogEvent.CANCLED,closeNativeDialogHandler);
	dialog.removeEventListener(NativeDialogEvent.CLOSED,closeNativeDialogHandler);
	dialog.removeEventListener(NativeDialogEvent.OPENED,traceEvent);
	dialog.removeEventListener(NativeExtensionErrorEvent.ERROR,onError);
	dialog.kill();
}

private function onListChange(event:NativeDialogListEvent):void
{
        var dialog:NativeListDialog = (event.target as NativeListDialog)
	if(dialog.selectedIndex>-1){
		selectedIndex = dialog.selectedIndex;
	}else{
		const a:Vector.<String> = dialog.selectedLabels;
		if(a.length>0){
			for (var i:int = 0; i < a.length; i++) 
			{
				trace(a[i]);
			}
		}
	}
}

like always available themes for android :

THEME_DEVICE_DEFAULT_DARK
THEME_DEVICE_DEFAULT_LIGHT
THEME_HOLO_DARK
THEME_HOLO_LIGHT
THEME_TRADITIONAL

All my extensions are compiled by Android SDK revision 12 (Android 3.1).

Advertisements
Tagged

2 thoughts on “as3 Android native multi-choice (single) dialog for adobe Air

  1. Richard says:

    Hello, I have been exploring the use of all your native extensions, for the most part they work great. However, I am having an odd issue with the Single Choice List on the iPad, it works perfectly on my Android tablet allowing me to select only one item in the list but on the iPad the dialog closes immediately after an item has been selected rather than waiting for me to press one of the buttons I have added. I expect that this could be the expected behaviour if there are no buttons added but is there some way to override that behaviour, in my case I want the OK/Cancel buttons I have added to close the dialog, so that a user can confirm they have selected the appropriate option. Thanks for your help.

    • Temporary this is the default behavior on IOS.
      The extension uses SBTableAlert (by blommegard) and I didn’t focus on it to make it work differently.
      Go ahead and make change if You like. I’m pretty busy at the moment but when I have some more time I will make some changes to the extension – basicly fixes

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: