📄 showlistui.java
字号:
/*
* BookList.java
*
* Created on 2006年8月24日, 下午10:49
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package cn.edu.nwpu.MobileCampusClinet;
import cn.edu.nwpu.MobileCampusServer.*;
import javax.microedition.lcdui.*;
import java.util.Vector;
import javax.microedition.midlet.MIDlet;
/**
*
* @author NickJava
*/
public class ShowListUI extends List implements CommandListener{
private Form ShowElement;
private Display display;
private Displayable displayable;
private Command OKCommand;
private Command backCommand;
private MIDlet midlet;
private StringItem stringItem;
private SearchFormUI searchFrom;
private Vector showArray;
private int flag;
/** Creates a new instance of BookList */
public ShowListUI(String title,MIDlet midlet,Displayable displayable,Vector showArray,int flag) {
super(title, Choice.IMPLICIT);
ShowElement=new Form(null);
OKCommand = new Command("确定", Command.OK , 5);
backCommand = new Command("返回",Command.BACK,5);
this.showArray=showArray;
this.midlet=midlet;
this.display=Display.getDisplay(midlet);
this.displayable=displayable;
this.flag=flag;
appendElement(flag);
addCommand(OKCommand);
addCommand(backCommand);
setCommandListener(this);
}
//向列表屏添加单词和图书名
public void appendElement(int conts){
switch(conts){
case 0 :
for(int i=0 ; i<showArray.size();i++){
DictionaryBean show_Word=(DictionaryBean)showArray.elementAt(i);
append(show_Word.getWord(),null);
}
searchFrom=new SearchFormUI("英汉查询","请输入要查询的单词",midlet ,displayable,0);
break;
case 1:
for(int i=0 ; i<showArray.size();i++){
BookBean book_Name=(BookBean)showArray.elementAt(i);
append(book_Name.getBookname(),null);
}
searchFrom=new SearchFormUI("图书查询系统","简单查询",midlet ,displayable,1);
break;
}
}
//查看具体的单词或图书的详细情况
public void getElementForm(int cont){
int num=this.getSelectedIndex();
switch(cont){
case 0 :
DictionaryBean word=(DictionaryBean)showArray.elementAt(num);
stringItem= new StringItem(word.getWord(), " \r\n单词意思 :\r\n"+word.getMeaning()
+" \r\n音标 :"+word.getPronunciation());
break;
case 1 :
ShowElement.deleteAll();
BookBean book=(BookBean)showArray.elementAt(num);
stringItem= new StringItem(book.getBookname(), " \r\n索取号 :"+book.getIndexid()
+" \r\n出版社 :"+book.getPublisher()
+" \r\n藏书地点 :"+book.getDepository()
+" \r\n借阅状态 :"+book.getState()
+" \r\n还书日期 :"+book.getReturndate());
break;
}
ShowElement.append(stringItem);
ShowElement.addCommand(backCommand);
ShowElement.setCommandListener(this);
}
public void commandAction(Command c,Displayable d){
if(c==OKCommand){
getElementForm(flag);
display.setCurrent(ShowElement);
}
if(c==backCommand){
display.setCurrent(searchFrom);
}
if(d.equals(ShowElement)){
if(c==backCommand){
display.setCurrent(this);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -