Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

21
LINES

< > BotCompany Repo | #552 // Android SL4A Python Example

Document

 import android
 
 droid=android.Android()
 droid.dialogCreateAlert("I like swords.","Do you like swords?")
 droid.dialogSetPositiveButtonText("Yes")
 droid.dialogSetNegativeButtonText("No")
 droid.dialogShow()
 response=droid.dialogGetResponse().result
 droid.dialogDismiss()
 if response.has_key("which"):
   result=response["which"]
   if result=="positive":
     print "Yay! I like swords too!"
   elif result=="negative":
     print "Oh. How sad."
 elif response.has_key("canceled"): # Yes, I know it's mispelled.
   print "You can't even make up your mind?"
 else:
   print "Unknown response=",response

 print "Done"

download  show line numbers   

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

Comments [hide]

ID Author/Program Comment Date
937 #1000604 (pitcher) 2015-08-20 15:28:24
936 #1000610 Edit suggestion:
!636
!629

main {
static Object androidContext;
static String programID;

public static void main(String[] args) throws Exception {
import android

droid=android.Android()
droid.dialogCreateAlert("I like swords.","Do you like swords?")
droid.dialogSetPositiveButtonText("Yes")
droid.dialogSetNegativeButtonText("No")
droid.dialogShow()
response=droid.dialogGetResponse().result
droid.dialogDismiss()
if response.has_key("which"):
result=response["which"]
if result=="positive":
print "Yay! I like swords too!"
elif result=="negative":
print "Oh. How sad."
elif response.has_key("canceled"): # Yes, I know it's mispelled.
print "You can't even make up your mind?"
else:
print "Unknown response=",response

print "Done"
}}
2015-08-20 05:53:44  delete 

add comment

Snippet ID: #552
Snippet name: Android SL4A Python Example
Eternal ID of this version: #552/1
Text MD5: 27a35685230800f5c386ede62bbaed6b
Author: stefan
Category:
Type: Document
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-03-27 20:21:30
Source code size: 643 bytes / 21 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 1017 / 170
Referenced in: [show references]