plist.java

来自「里面是关于手机通讯部的开发 主要实现了帐号的登陆」· Java 代码 · 共 89 行

JAVA
89
字号
package pass;

import javax.microedition.lcdui.*;
import javax.microedition.rms.*;

public class plist extends List implements CommandListener {
  private mypass tmain;
  private Display display;
  private  String buff[][]=new String[100][2];
  public plist(mypass main) {
    super("账号列表", List.IMPLICIT);
    tmain=main;
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }

  private void jbInit() throws Exception {
    int i;
    display=Display.getDisplay(tmain);
    RecordSet Record=new RecordSet();
    Record.open("accounts",true);
    buff=new String[Record.Recordcount()][2];
    buff=Record.getrecord();
    Record.close();
    System.out.println(buff.length);
    for(i=0;i<buff.length;i++)
    {
      append(getsubstr(buff[i][1],0),null);
    }
    addCommand(new Command("更多", Command.OK, 1));
    setCommandListener(this);
  }
  public void commandAction(Command command, Displayable displayable) {
    int i = this.getSelectedIndex();
    int id =0;
    String tacc =null;
    String tpass = null;
    String taccName=null;
    String treadme=null;
    if(i>=0){
    id = Integer.parseInt(buff[i][0]);
    taccName = getsubstr(buff[i][1], 0);
    tacc = getsubstr(buff[i][1], 1);
    tpass = getsubstr(buff[i][1], 2);
    treadme = getsubstr(buff[i][1], 4);
    }
    if(command==List.SELECT_COMMAND)
    {
     passview();
    }
    if(command.getCommandType()==Command.OK)
    {
      display.setCurrent(new menu(tmain,id,taccName,tacc,tpass,treadme));
    }
  }
  public String getsubstr(String str ,int index)
    {
      String rStr="no found";
      String indexStr="("+String.valueOf(index)+")";
      String indexlastStr="("+String.valueOf(++index)+")";
      int keylen=indexStr.length();
      int statID=str.indexOf(indexStr);
      int endID=str.indexOf(indexlastStr);
      if(endID>0)
      {
        if(statID==-1)
          rStr = str.substring(0, endID);
        else
        rStr=str.substring(statID+keylen,endID);
      }
      return rStr;
   }

  private void passview()
  {
    String tmpStyle;
    int i=this.getSelectedIndex();
    tmpStyle="账号:\n"+getsubstr(buff[i][1],1)+"\n";
    tmpStyle=tmpStyle+"密码:\n"+getsubstr(buff[i][1],2)+"\n";
    tmpStyle=tmpStyle+"修改日期:\n"+getsubstr(buff[i][1],3)+"\n";
    tmpStyle=tmpStyle+"说明:\n      "+getsubstr(buff[i][1],4)+"\n";
     mypass.Msgokbox(this,getsubstr(buff[i][1],0),tmpStyle,AlertType.INFO);
  }
}

⌨️ 快捷键说明

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