?? viewnote.java
字號:
/*
* ViewNote.java
*
* Created on 2007年3月15日, 上午10:09
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package net.bccn.account.ui;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;
import net.bccn.account.model.Note;
import net.bccn.account.util.Util;
/**
*
* @author hadeslee
*/
public class ViewNote extends List implements CommandListener{
private static ViewNote me;
private Command view,modify,delete,back;
private Note[] notes;
/** Creates a new instance of ViewNote */
private ViewNote() {
super("查看筆記",Choice.EXCLUSIVE);
initWindow();
}
private void initWindow(){
this.setFitPolicy(Choice.TEXT_WRAP_OFF);
view=new Command("查看",Command.OK,1);
modify=new Command("修改",Command.SCREEN,2);
delete=new Command("刪除",Command.SCREEN,3);
back=new Command("返回",Command.BACK,0);
this.addCommand(view);
this.addCommand(modify);
this.addCommand(delete);
this.addCommand(back);
this.setCommandListener(this);
}
public static ViewNote getInstance(){
if(me==null){
me=new ViewNote();
}
return me;
}
public static void showViewNote(Note[] notes){
if(me==null){
me=new ViewNote();
}
me.notes=notes;
me.deleteAll();
for(int i=0;i<notes.length;i++){
me.append(notes[i].toString(),null);
}
}
public static void updateList(Note note){
for(int i=0;i<me.notes.length;i++){
if(note.getID()==me.notes[i].getID()){
me.notes[i]=note;
me.set(i,note.toString(),null);
}
}
}
public void commandAction(Command command, Displayable displayable) {
if(command==back){
Util.changeTo(Util.VIEW_NOTE_FORM);
}else if(command==view){
int index=this.getSelectedIndex();
Util.moveTo(AddNote.getInstance(notes[index],false));
}else if(command==modify){
int index=this.getSelectedIndex();
Util.moveTo(AddNote.getInstance(notes[index],true));
}else if(command==delete){
int index=this.getSelectedIndex();
boolean b=Util.deleteRecord(notes[index]);
if(b){
Util.showINFO(AlertType.INFO,"筆記刪除成功!!");
Note[] newNs=new Note[notes.length-1];
boolean add=false;
//如果找到了刪除的那個下標,那么后面的元素就要加一了
for(int i=0;i<newNs.length;i++){
if(i==index){
add=true;
}
if(add){
newNs[i]=notes[i+1];
}else{
newNs[i]=notes[i];
}
}
notes=newNs;
this.delete(index);
}else{
Util.showINFO(AlertType.ERROR,"筆記刪除失敗!!");
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -