lwuit-List控件使用
来源:技术人生 责任编辑:栏目编辑 发表时间:2013-07-02 06:39 点击:次
List控件的使用是很频繁的,今天就介绍一下Lwuit中List的使用方法:
private String globalstrURL = "";
public void initform() {
removeAll();
removeAllCommands();
String[][] strAccessories = EsionData.getInstance()
.GetSiteList("05342");
this.addCommand(new Command("返回", 0) {
public void actionPerformed(ActionEvent ev) {
FormFactory.getInstance().getMainForm().show();
}
});
if (strAccessories != null) {
SiteListInfo[] accessoryinfoarray = new SiteListInfo[strAccessories.length];
Image img = getRes().getImage("YdFj.gif");
for (int i = 0; i < strAccessories.length; i++) {
accessoryinfoarray[i] = new SiteListInfo(strAccessories[i][0],
strAccessories[i][1], img);
}
// 设置使得list的选中状态的层能够自适应的足够撑开
setLayout(new BorderLayout());
setScrollable(false);
//创建List并传入相应的数据
addComponent(BorderLayout.CENTER, createList(accessoryinfoarray,
List.VERTICAL, new ContactsRenderer()));
this.addCommand(new Command("确定", 1) {
public void actionPerformed(ActionEvent ev) {
try {
EsionMIDlet.midlet.platformRequest(globalstrURL);
} catch (ConnectionNotFoundException e) {
e.printStackTrace();
}
}
});
} else
addComponent(new Label("网络出现异常,没有找到任何资讯站点!"));
}
// List初始化
private List createList(final SiteListInfo[] SiteLists, int orientation,
ListCellRenderer renderer) {
final List list = new List(SiteLists);
list.getStyle().setBgTransparency(0);
list.setListCellRenderer(renderer);
list.setOrientation(orientation);
// list列表选择焦点监听事件
相关新闻>>
- 发表评论
-
- 最新评论 更多>>