bada编程 - 在列表视图中调用listview

时间:2011-12-07 05:30:25

标签: c++ listview bada

我目前有一个包含4个项目的列表视图,在listview项目之一中,我想实现另一个listview,我是否还要做另一个表单管理器?或者我该怎么做呢?另外,如何在另一个类中调用一个类的函数?或者做一个引用(指针)将信息从一个类传递到另一个类?

1 个答案:

答案 0 :(得分:0)

我不确定我是否理解这个问题。

简而言之,您需要从一个列表视图到另一个列表视图的指针。如果你在一个表单中,那么指向列表视图的本地指针就足够了。

同样适用于引用类实例:

class Apple() {
  private Basket* basket;
  public Apple() { 
    basket = null;
  }
  public void setBasket(Basket* basket) {
    this->basket = basket;
  }
  public Basket* getBasket() {
    return this->basket;
  }
}

class Basket() {
  private Apple* apple;
  public Basket() {
    apple = null;
  }
  public setApple(Apple* apple) {
    this->apple = apple;
    this->apple->setBasket(this);
  }
}

...
Apple* apple = new Apple();
Basket* basket = new Basket()
basket->setApple(apple);

希望它有所帮助。

好的,我在这里添加更多代码,看它是否有帮助它没有经过测试,即时编写显示主体

FormA.h

class FormA : 
    public Osp::Ui::Controls::Form, 
    public Osp::Ui::IItemEventListener 
{

    // Other stuff including list
protected:
  void  OnItemStateChanged (const Osp::Ui::Control &source, int index, int itemId, Osp::Ui::ItemStatus status);   
}

FormA.cpp

    // Other stuff including constructor and list control creation/population

void FormA::OnItemStateChanged (const Osp::Ui::Control &source, int index, int itemId, Osp::Ui::ItemStatus status) {

  // Construct and show other form
  FormB* b = new FormB(itemId);
  // Add to frame and set formb as current

}

FormB.h

class FormA : 
    public Osp::Ui::Controls::Form, 
    public Osp::Ui::IItemEventListener 
{
private int itemId;
public:
  FormA(int itemId);  
}

FormB.cpp

FormA::FormA(int itemId) {
 this->itemId = itemId;
}

// Now somewhere in your form initialization read the itemId
// value (this->itemId) and decide what you want to show in the form's list view