⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scanbookscreen.java

📁 J2ME的源码!我以前学习J2ME的源码哈!非常适合初学者
💻 JAVA
字号:
package telphonebook;

import java.util.Vector;

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 javax.microedition.rms.InvalidRecordIDException;
import javax.microedition.rms.RecordEnumeration;
import javax.microedition.rms.RecordStoreException;
import javax.microedition.rms.RecordStoreNotOpenException;

public class ScanBookScreen extends List implements CommandListener {

	private static final String LOOK = "鏌ョ湅";

	private Vector friendID;

	public ScanBookScreen() {
		super(Constant.TITLE_SCAN_BOOK_SCREEN, Choice.IMPLICIT);
		initCommand();
		initFriendInfo();
	}

	private void initFriendInfo() {
		try {
			RecordEnumeration re = Constant.telphoneStore.enumerateRecords(null,
					new NameComparator(), true);
			friendID = new Vector();
			while (re.hasNextElement()) {
				int id = re.nextRecordId();
				friendID.addElement(new Integer(id));
				Account friend = Account.decode(Constant.telphoneStore.getRecord(id));
				append(friend.getName(), null);
			}
			re.destroy();
		} catch (RecordStoreNotOpenException e) {
			e.printStackTrace();
		} catch (InvalidRecordIDException e) {
			e.printStackTrace();
		} catch (RecordStoreException e) {
			e.printStackTrace();
		}
	}

	private void initCommand() {
		addCommand(new Command(LOOK, Command.OK, 0));
		addCommand(Constant.BACK_COMMAND);
		setCommandListener(this);
	}

	public void commandAction(Command cmd, Displayable arg1) {
		String label = cmd.getLabel();
		if (label.equals(LOOK)) {
			toEditorDetailScreen();
		} else if (label.equals(Constant.BACK)) {
			Constant.toMainScreen();
		}
	}

	private void toEditorDetailScreen() {
		int count = friendID.size();
		if (count == 0)
			return;
		int recordID = ((Integer) friendID.elementAt(getSelectedIndex()))
				.intValue();
		try {
			Account friend = Account.decode(Constant.telphoneStore.getRecord(recordID));
			EditorDetailScreen detail = new EditorDetailScreen(this, friend, recordID);
			Constant.diaplay.setCurrent(detail);
		} catch (RecordStoreNotOpenException e) {
			e.printStackTrace();
		} catch (InvalidRecordIDException e) {
			e.printStackTrace();
		} catch (RecordStoreException e) {
			e.printStackTrace();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -