Codenameone,如何将一个值绑定到 MultiButton 项而不在 UI 上显示它
Codenameone, How can i bind a value to the MultiButton item without displaying it on UI
我正在从 ArrayList 创建一个多按钮,涉及两个键。 "id" 和 "code"。我只想在 UI 上显示 "code" 并隐藏 "id" 因为我只需要 "id" 作为 actionListener。
我的做法,开放修正
我只想显示 TextLine1 ["code"] 并隐藏 TextLine2 ["id"]
for(int x= 0; x < policies2.size(); x++)
{
final MultiButton mb = new MultiButton();
Double policy_id = (Double)policies2.get(x).get("id");
mb.setTextLine1((String) policies2.get(x).get("code"));
mb.setTextLine2(policies2.get(x).get("policy_id")+""); //how can i hide this/bind it to the Multi withou showing it on the UI.
mb.addActionListener(new ActionListener(){
//use "id" here
//mb.getTextLine2()
}
}
如何使用 "id" 而不在 UI
上显示它
这其实很简单。
我只是在 addActionListener 内部 class 之外将 id 声明为最终的,我不必将它设置为 TextLine2.
final Double db = (Double)policies2.get(x).get("policy_id");
mb.addActionListener(new ActionListener(){
System.out.println(db);
}
试试这个:
final MultiButton mb = new MultiButton();
final Double policy_id = (Double)policies2.get(x).get("id");
mb.setTextLine1((String) policies2.get(x).get("code"));
//mb.setTextLine2(policies2.get(x).get("policy_id")+""); //how can i hide this/bind it to the Multi withou showing it on the UI.
mb.addActionListener(new ActionListener(){
public void actiobPerformed(ActionEvent e){
double id = policy_id.doubleValue();
...
}
}
}
我正在从 ArrayList 创建一个多按钮,涉及两个键。 "id" 和 "code"。我只想在 UI 上显示 "code" 并隐藏 "id" 因为我只需要 "id" 作为 actionListener。
我的做法,开放修正
我只想显示 TextLine1 ["code"] 并隐藏 TextLine2 ["id"]
for(int x= 0; x < policies2.size(); x++)
{
final MultiButton mb = new MultiButton();
Double policy_id = (Double)policies2.get(x).get("id");
mb.setTextLine1((String) policies2.get(x).get("code"));
mb.setTextLine2(policies2.get(x).get("policy_id")+""); //how can i hide this/bind it to the Multi withou showing it on the UI.
mb.addActionListener(new ActionListener(){
//use "id" here
//mb.getTextLine2()
}
}
如何使用 "id" 而不在 UI
上显示它这其实很简单。 我只是在 addActionListener 内部 class 之外将 id 声明为最终的,我不必将它设置为 TextLine2.
final Double db = (Double)policies2.get(x).get("policy_id");
mb.addActionListener(new ActionListener(){
System.out.println(db);
}
试试这个:
final MultiButton mb = new MultiButton();
final Double policy_id = (Double)policies2.get(x).get("id");
mb.setTextLine1((String) policies2.get(x).get("code"));
//mb.setTextLine2(policies2.get(x).get("policy_id")+""); //how can i hide this/bind it to the Multi withou showing it on the UI.
mb.addActionListener(new ActionListener(){
public void actiobPerformed(ActionEvent e){
double id = policy_id.doubleValue();
...
}
}
}