2011-12-05 55 views
0

我想为标签分配TextField。我使用以下代码LWUIT:如何将标签分配给Textfield

TextField textField = new TextField(); 
Label label = new Label("Pick a unique username"); 
textField.setLabelForComponent(label); 
textField.setConstraint(TextField.ANY); 
form.addComponent(textField); 
form.show(); 

上面的代码不表示在TextField的相关联的标签。如何做呢 ?

回答

1

Component从LWUIT的Javadoc @link

public void setLabelForComponent(Label componentLabel) 

Allows us to indicate the label associated with this component thus providing 
visual feedback related for this component e.g. starting the ticker when the 
component receives focus. 

Parameters:  
componentLabel - a label associated with this component 

摘录因此你只是关联与此Component现在实际结合在一起感知/视觉单组一个Label

我会建议你使用ComponentGroupTextFieldLabel添加到它,也可以作为一个组的样式。检查ComponentGroup

PS this链接,了解更多信息:ComponentGroup可从LWUIT 1.5

+0

感谢您的帮助,它真的有效, –

+0

WC,考虑接受这个答案,以帮助未来读者的这篇文章。 – Vimal