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

📄 htmlselect.java.svn-base

📁 开发框架。 一.说明: 此框架的意图是解决手机软件开发中常遇到
💻 SVN-BASE
字号:
package org.gggeye.easymf.ui;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;

import org.gggeye.easymf.midlet.MIDletManager;

public class HtmlSelect extends View {

	private SelectOptionGUI sgui;
	int listType;

	int selectIndex;
	SelectOption[] selectOption;
	String name;
	String iValue;

	/**
	 * label
	 * 
	 * @param text
	 * @param values
	 * @param maxSize
	 */
	public HtmlSelect(String _name, String _value, String _iName,
			String _iValue, int _listType) {
		super(0xCEF, 0x0, null);
		this.name = _name;
		this.value = _value;
		this.name = _iName;
		this.iValue = _iValue;
		listType = _listType;
		this.hasFocus = true;
	}

	public void doClick(int keyCode) {
		// if (keyCode == 8) {
		openGUIFor();
		// }

	}

	private void openGUIFor() {
		sgui = new SelectOptionGUI(this.listType);
		MIDletManager.show(sgui);
	}

	/**
	 * 发现实现多选是没有意义的。
	 * 
	 * @author fox
	 * 
	 */
	class SelectOptionGUI extends List implements
			javax.microedition.lcdui.CommandListener {
		Command ok = new Command("确定", Command.OK, Command.OK);

		Command cancel = new Command("取消", Command.CANCEL, Command.CANCEL);

		public SelectOptionGUI(int listType) {
			super("列表选择", listType == 0 ? List.EXCLUSIVE : List.IMPLICIT);
			this.addCommand(ok);
			this.addCommand(cancel);
			this.setCommandListener(this);
			if (selectOption != null) {
				for (int j = 0; j < selectOption.length; j++) {
					append(selectOption[j].name, null);
				}
			}
		}

		public void commandAction(Command c, Displayable d) {
			if (c.getPriority() == 0 || c == ok) {
				selectIndex = sgui.getSelectedIndex();
			}
			MIDletManager.show(d);

		}

	}

	public void doPaint(Pen point, HtmlDocument _htmlDocument) {
		if (_htmlDocument.focusIndex == this.index) {
			point.save();
			point.setColor(backColor);
			point.drawRects(left, top, width, height);
			point.reset();
		}
		point.save();
		point.setColor(0x0);
		point.drawRect(left, top, width, height);
		int w = 16;
		int h = this.font.getHeight()>>2;
		int s = left + width - w;
		w = w>>2;
		
		point.drawLine(s, top, s, buttom);
		//绘制三角形
		point.setColor(0x0);
		s+=w;
		point.fillTriangle(s , top + h, s+2*w, top + h, s+w, top + 3*h);
		// point.fillTriangle(s + w << 1, top + height / 3, s + w << 2,
		// top + height >> 2,
		// s + (w << 2) * 3, top + height << 2);
		try {
			point.drawString(selectOption[this.selectIndex].name, left + 2, top,
							20);
		} catch (Exception e) {
			// #if (debug == true)
			e.printStackTrace();
			// #endif
		}

	}
	
	String getValue(){
		return selectOption[this.selectIndex].value;
	}
}


class SelectOption {
	String name;
	String value;

	public SelectOption(String name, String value) {
		this.name = name;
		this.value = value;
	}
}

⌨️ 快捷键说明

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