本文整理汇总了Java中com.codename1.ui.Form.getBackCommand方法的典型用法代码示例。如果您正苦于以下问题:Java Form.getBackCommand方法的具体用法?Java Form.getBackCommand怎么用?Java Form.getBackCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.codename1.ui.Form
的用法示例。
在下文中一共展示了Form.getBackCommand方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reloadForm
import com.codename1.ui.Form; //导入方法依赖的package包/类
/**
* Useful tool to refresh the current state of a form shown using show form
* without pushing another instance to the back stack
*/
public void reloadForm() {
Form currentForm = Display.getInstance().getCurrent();
Command backCommand = currentForm.getBackCommand();
Form newForm = (Form)createContainer(fetchResourceFile(), currentForm.getName());
if (backCommand != null) {
setBackCommand(newForm, backCommand);
// trigger listener creation if this is the only command in the form
getFormListenerInstance(newForm, null);
for(int iter = 0 ; iter < currentForm.getCommandCount() ; iter++) {
if(backCommand == currentForm.getCommand(iter)) {
newForm.addCommand(backCommand, newForm.getCommandCount());
break;
}
}
}
beforeShow(newForm);
Transition tin = newForm.getTransitionInAnimator();
Transition tout = newForm.getTransitionOutAnimator();
currentForm.setTransitionInAnimator(CommonTransitions.createEmpty());
currentForm.setTransitionOutAnimator(CommonTransitions.createEmpty());
newForm.setTransitionInAnimator(CommonTransitions.createEmpty());
newForm.setTransitionOutAnimator(CommonTransitions.createEmpty());
newForm.layoutContainer();
newForm.show();
postShowImpl(newForm);
newForm.setTransitionInAnimator(tin);
newForm.setTransitionOutAnimator(tout);
}
示例2: goBack
import com.codename1.ui.Form; //导入方法依赖的package包/类
/**
* Executes the back command for the current form, similarly to pressing the back button
*/
public static void goBack() {
if(verbose) {
log("goBack()");
}
Form f = Display.getInstance().getCurrent();
Command c = f.getBackCommand();
assertBool(c != null, "The current form doesn't have a back command at this moment! for form name " + f.getName());
f.dispatchCommand(c, new ActionEvent(c,ActionEvent.Type.Command));
waitFor(20);
}
示例3: onOptionsItemSelected
import com.codename1.ui.Form; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
super.onOptionsItemSelected(item);
final Form currentForm = Display.getInstance().getCurrent();
if (currentForm == null) {
return false;
}
Command cmd = null;
final boolean[] tmpProp = new boolean[1];
if (item.getItemId() == android.R.id.home) {
cmd = currentForm.getBackCommand();
if (cmd == null) {
return false;
}
cmd.putClientProperty("source", "ActionBar");
tmpProp[0] = true;
}
int commandIndex = item.getItemId();
if (cmd == null) {
cmd = currentForm.getCommand(commandIndex);
}
final Command command = cmd;
final ActionEvent actionEvent = new ActionEvent(command);
//stop edit if the keybaord is open
AndroidImplementation.stopEditing();
// Protect ourselves from commands that misbehave. A crash here will crash the entire application
Display.getInstance().callSerially(new Runnable() {
@Override
public void run() {
try {
currentForm.dispatchCommand(command, actionEvent);
//remove the temp source property
if (tmpProp[0]) {
command.putClientProperty("source", null);
}
} catch (Throwable e) {
Log.e("CodenameOneActivity.onOptionsItemSelected", e.toString() + Log.getStackTraceString(e));
}
}
});
return true;
}
示例4: createForm
import com.codename1.ui.Form; //导入方法依赖的package包/类
Form createForm(Form f) {
Form currentForm = Display.getInstance().getCurrent();
if(currentForm != null && currentForm instanceof Dialog) {
((Dialog)Display.getInstance().getCurrent()).dispose();
currentForm = Display.getInstance().getCurrent();
}
Vector formNavigationStack = baseFormNavigationStack;
if(formNavigationStack != null && !(f instanceof Dialog) && !f.getName().equals(homeForm)) {
if(currentForm != null) {
String nextForm = (String)f.getClientProperty("%next_form%");
// we are in the sidemenu view we should really be using the parent form
SideMenuBar b = (SideMenuBar)currentForm.getClientProperty("cn1$sideMenuParent");
if(b != null) {
currentForm = b.getParentForm();
}
// don't add back commands to transitional forms
if(nextForm == null) {
String commandAction = currentForm.getName();
if(allowBackTo(commandAction) && f.getBackCommand() == null) {
Command backCommand;
if(isSameBackDestination(currentForm, f)) {
backCommand = currentForm.getBackCommand();
} else {
backCommand = createCommandImpl(getBackCommandText(currentForm.getTitle()), null,
BACK_COMMAND_ID, commandAction, true, "");
backCommand.putClientProperty(COMMAND_ARGUMENTS, "");
backCommand.putClientProperty(COMMAND_ACTION, commandAction);
}
if(backCommand != null) {
setBackCommand(f, backCommand);
}
// trigger listener creation if this is the only command in the form
getFormListenerInstance(f, null);
formNavigationStack.addElement(getFormState(currentForm));
}
}
}
}
return f;
}