我正在从ArrayList创建一个Multibutton,涉及两个键。 “id”和“code”。我只想在UI上显示“代码”并隐藏“id”,因为我只需要actionListener的“id”。
我的方法,开放进行更正
我只想显示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上显示
答案 0 :(得分:1)
实际上这很简单。 我刚刚将addActionListener内部类的id声明为final,我没有必要将它设置为TextLine2。
final Double db = (Double)policies2.get(x).get("policy_id");
mb.addActionListener(new ActionListener(){
System.out.println(db);
}
答案 1 :(得分:1)
试试这个:
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();
...
}
}
}