2

Just getting started with PhoneGap and looking for a way to create the kind of dialog shown here: http://developer.android.com/guide/topics/ui/dialogs.html#AddingAList but only found notification.alert and notification.confirm - but there must be some way to create a list dialog?

2 Answers 2

1

Just use a <select/> box in your html. When you click on it that is the type of dialog box that will be shown.

Sign up to request clarification or add additional context in comments.

Comments

1

I created a Phonegap Android Plugin for this. When working with Phonegap Android plugin, you need to do:

  1. Add the Java file in the /src folder
  2. Update your /res/xml/config.xml for your Phonegap plugin settings
  3. Call your the plugin with cordova.exec() in your HTML/Javascript

Do check the Phonegap plugin development if you need extra guide on that.

You can download my AlertDialog List plugin at github.

Assuming you have your Phonegap Android Eclipse setup properly, together with the plugin, in your HTML/Javascript, you can just call something like this.

<script>
var fruitlist = [
        "The Fruit List Title", // this is the title 
        "Orange", 
        "Apple", 
        "Watermelon", 
        "Papaya", 
        "Banana", 
        "Pear" 
    ];

function showlist(thelist) {
    cordova.exec(
        function(listitem) {
            alert( "You selected "+ thelist[listitem] );
        }, 
        function(error) {
            alert("Error Occured");
        }, "AlertList", "alertlist", thelist );
}
</script>

<a href="javascript:showlist(fruitlist)">Pick your fruit</a>

I think I should also remind you that you need to load cordova properly in your HTML/Javascript. We do that by listening to deviceready event. Otherwise, cordova.exec won't work. This is like the $(document).ready in jQuery.

document.addEventListener("deviceready", your_function, false);

AlertDialog List Phonegap Android Plugin

https://github.com/kidino/phonegap-alertdialoglist-plugin

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.