?? searchcontroller.java
字號:
package com.j2medev.chapter4;
import javax.microedition.lcdui.*;
public class SearchController implements CommandListener{
private SearchMIDlet midlet = null;
private RMSHandler database = null;
private Display display = null;
private InputUI input = new InputUI(this);
private List result = new List("查詢結果",List.IMPLICIT);
public static final Command backCommand = new Command("返回",Command.BACK,1);
public static final Command exitCommand = new Command("退出",Command.EXIT,2);
public SearchController(SearchMIDlet midlet) {
this.midlet = midlet;
display = Display.getDisplay(midlet);
database = new RMSHandler();
input.addCommand(exitCommand);
input.setCommandListener(this);
result.addCommand(backCommand);
result.addCommand(exitCommand);
result.setCommandListener(this);
display.setCurrent(input);
}
public String[] getResult(String query){
return database.getResult(query);
}
public void displayResult(String[] queryResult){
if(queryResult == null){
queryResult = new String[]{"查詢結果為空"};
}
result.deleteAll();
for(int i = 0;i<queryResult.length;i++){
result.append(queryResult[i],null);
}
display.setCurrent(result);
}
public void commandAction(Command cmd,Displayable displayable){
if(cmd == backCommand){
display.setCurrent(input);
}else if(cmd == exitCommand){
midlet.exit();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -