📄 listphoneui.java
字号:
/*
* Created on 2004-6-25
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.north.phonebook.ui;
import javax.microedition.lcdui.*;
import com.north.phonebook.model.*;
/**
* @author P2800
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
public class ListPhoneUI extends List implements CommandListener
{
private UIController uicontroller;
//private int listNum = 0;
//private int lastSize = 0;
public static final Command backCommand = new Command("返回", Command.BACK, 2);
public static final Command infoCommand = new Command("详情", Command.ITEM, 1);
public static final Command deleCommand = new Command("删除", Command.OK, 3);
public ListPhoneUI(UIController uicontroller)
{
super(Title.listPhoneTitle, List.IMPLICIT);
this.uicontroller = uicontroller;
this.addCommand(backCommand);
this.addCommand(deleCommand);
this.addCommand(infoCommand);
this.setCommandListener(this);
}
public void init(Index[] index)
{
/*
for (int i = lastSize-1; i >= 0; i--)
{
delete(i);
}
*/
deleteAll();
for (int i = 0; i < index.length; i++)
{
append(index[i].getKey(), null);
}
//lastSize = index.length;
}
public void deleteAll()
{
int size = size();
for(int i = size-1;i>=0;i--)
{
delete(i);
}
}
/*
public void subLastSize()
{
lastSize--;
}
*/
/*
* (non-Javadoc)
*
* @see javax.microedition.lcdui.CommandListener#commandAction(javax.microedition.lcdui.Command,
* javax.microedition.lcdui.Displayable)
*/
public void commandAction(Command arg0, Displayable arg1)
{
// TODO Auto-generated method stub
if (arg0 == backCommand)
{
uicontroller
.handleEvent(UIController.EventID.EVENT_LISTPHONE_BACK_MAINUI);
} else if (arg0 == deleCommand)
{
if(size()==0)
{
uicontroller.showAlert("无效操作!",this,AlertType.WARNING);
return;
}
String record = getString(getSelectedIndex());
int index = getSelectedIndex();
uicontroller.handleEvent(UIController.EventID.EVENT_DELETE_RECORD,
new Object[] { record, new Integer(index) });
} else if (arg0 == infoCommand)
{
if(size()==0)
{
uicontroller.showAlert("无效操作!",this,AlertType.WARNING);
return;
}
String record = getString(getSelectedIndex());
uicontroller.handleEvent(
UIController.EventID.EVENT_DISPLAY_INFOMATION,
new Object[] { record });
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -