EasyMF ListView 的使用

今天晚上回到家,构思了下ListView的实现
本来想ListView 是准备设计成一个可以伸缩的树状结构的,不过,由于时间关系,就暂时先实现一个简单的List吧

看看我的ListDemo的代码跟图片吧。


package org.gggeye.easymf.demo.ui;

import javax.microedition.lcdui.Displayable;

import org.gggeye.easymf.demo.Action;
import org.gggeye.easymf.demo.DemoApp;
import org.gggeye.easymf.midlet.MIDletManager;
import org.gggeye.easymf.ui.EventListener;
import org.gggeye.easymf.ui.ListView;
import org.gggeye.easymf.ui.Menu;
import org.gggeye.easymf.ui.MenuItem;
import org.gggeye.easymf.ui.View;
import org.gggeye.easymf.util.Tools;

public class ListDemo extends ListView implements EventListener{
   
   
    public ListDemo() {
        super("List Demo");
        this.setEventListener(this);
        createMenu();
    }
   
    final void createMenu(){
        Menu tMenu = new Menu(this);
        tMenu.addMenuItem(null, "添加", Action.LIST_DEMO_ADD, null);
        tMenu.addMenuItem(null, "插入", Action.LIST_DEMO_INSERT, null);
        tMenu.addMenuItem(null, "删除", Action.LIST_DEMO_DELETE, null);
         
        tMenu.setEventListener(this);
        tMenu.setRightMenu("返回", Action.GO_BACK);
        this.setMenu(tMenu);
    }

    public void htmlElementOnClick(View element) {
         
       
    }

    public void menuOnClick(MenuItem _item, Displayable _displayable) {
         int flag = _item.flag;
         switch(flag){
         case Action.GO_BACK: goBack(); break;
         
         case Action.LIST_DEMO_ADD: {
             
             
             this.addItem(Tools.readImage("/about.png"), "列表 " + this.size());
             break;
         }
         case Action.LIST_DEMO_INSERT: {
             int tIndex = this.getFocusItem().getIndex();
             this.addItem(Tools.readImage("/about.png"), "列表 " + tIndex);
             break;
         }
         case Action.LIST_DEMO_DELETE:{
             int tIndex = this.getFocusItem().getIndex();
             this.delete(tIndex);
             break;
         }
         }
    }
   
    void goBack(){
        ((DemoApp)MIDletManager.getMIDlet()).menuList.show();
    }

     

}


W+A|l�/~:dM33GEYE h*j}$GE0^['R
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值