我正在创建一个包含两个 ObjectChoiceFields 的 BlackBerry 应用程序。我想为每个人添加听众。我搜索了它,但没有找到任何有用的代码。
它就像网站上的国家/地区选择器。我正在寻找简单的逻辑,我不需要任何面向数据库的解决方案。谁能描述如何为这两个 ObjectChoiceField 添加侦听器?
我在下面附上了我的代码,但它只适用于国家选择领域。当我改变状态选择时没有任何反应。
public class MyApplication extends MainScreen implements FieldChangeListener
{
ObjectChouceField choice_c,choice_s;
public MyApplication ()
{
this.setTitle("hai");
choice_c = new MyChoiceField("Select a Country", countryArray);
choice_c.setChangeListener(this);
this.add(choice_c);
choice_s = new MyChoiceField("Select a State", stateArray);
choice_s.setChangeListener(this);
this.add(choice_s);
..................
..................
}
public void fieldChanged(Field field, int context)
{
if(field == choice_category)
{
Dialog.alert("choice country has been pressed");
}
else if(field == choice_round)
{
Dialog.alert("choice state has been pressed");
}
}
}