0

如何在 fullscreenwrapper2 和 sl4a 中为 OptionsMenuItem 制作事件处理程序?

    FullScreenWrapper2App.get_android_instance().addOptionsMenuItem("Exit","exit",None,"ic_menu_revert") # adding exit options successfully, but how to make event handler of this?
    self.views.exit.add_event(click_EventHandler(self.views.exit, self.close_out)) #this is works, trigger close_out function when clicked.
    self.views.but_exit.add_event(click_EventHandler("exit", self.close_out)) # and this is too! this is works, trigger close_out function when clicked.

任何人都可以让它出汗吗?

4

1 回答 1

0

解决了我自己的问题。add_event(EventHandler())用作 OptionsMenuItem 本身的处理程序。

class MainScreen(Layout):
    def __init__(self):
        #initialize your class data attributes
        #load & set your xml
        super(MainScreen,self).__init__(pathhelpers.read_layout_xml("main.xml"),"Some title")

    def on_show(self):
    FullScreenWrapper2App.get_android_instance().addOptionsMenuItem("Exit",'exit','exit',"ic_menu_revert")
    self.add_event(EventHandler("exit", None, None, None, self.close_out))
于 2012-11-21T04:45:48.680 回答