コード例 #1
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   menu.add(Menu.NONE, MenuId.ADD.getId(), Menu.NONE, "Add")
       .setIcon(android.R.drawable.ic_menu_add);
   menu.add(Menu.NONE, MenuId.PREFERENCES.getId(), Menu.NONE, "Preferences")
       .setIcon(android.R.drawable.ic_menu_preferences);
   menu.add(Menu.NONE, MenuId.HELP.getId(), Menu.NONE, "Help")
       .setIcon(android.R.drawable.ic_menu_help);
   return true;
 }
コード例 #2
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (resultCode == RESULT_OK) {
     final File script = new File(data.getStringExtra(Constants.EXTRA_SCRIPT_PATH));
     if (requestCode == MenuId.ADD.getId()) {
       Map<String, MethodDescriptor> eventMethodDescriptors =
           FacadeConfiguration.collectStartEventMethodDescriptors();
       final List<String> eventNames = Lists.newArrayList(eventMethodDescriptors.keySet());
       Collections.sort(eventNames);
       AlertDialog.Builder builder = new AlertDialog.Builder(this);
       builder.setItems(
           eventNames.toArray(new CharSequence[eventNames.size()]),
           new OnClickListener() {
             @Override
             public void onClick(DialogInterface dialog, int position) {
               mTriggerRepository.put(new ScriptTrigger(eventNames.get(position), script));
             }
           });
       builder.show();
     }
   }
 }