开发者

Connect Blackberry menuitem to onscreen buttons

开发者 https://www.devze.com 2023-02-25 12:37 出处:网络
I have requirement for having onscreen navigation buttons along with menu items on blackberry. I need to generate menu item commands as onscreen buttons. Is there a way to generate onscreen menu it开发

I have requirement for having onscreen navigation buttons along with menu items on blackberry. I need to generate menu item commands as onscreen buttons. Is there a way to generate onscreen menu it开发者_开发知识库em buttons in Blackberry? i.e On each screen of my application the menu items should be populated as onscreen buttons both having same functionality?

Thank you


The easiest way to accomplish what you're trying to do is write one function then have both the button and the menu item use the same function.

For example:

function doSomething() {
   // Your Code Here
}

// In the function building your screen
MenuItem somethingMi = new MenuItem() {
  private MenuItem() { super("Do Something",100001, 5); }

  public void run() { doSomething() };
}

Button somethingBtn = new ButtonField("Do Something");
somethingBtn.setChangeListener(new FieldChangeListener() {
  public void fieldChanged(Field field, int context){
    doSomething();
  }
}

addMenuItem(somethingMI);
add(somethingBtn);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号