예제 #1
0
  /** 初始化 */
  private void initView() {
    et_input = (EditText) findViewById(R.id.et_input);
    tv_time = (TextView) findViewById(R.id.tv_time);
    tv_time.setOnClickListener(this);

    /* 首选项*/
    sp_machine_no = getSharedPreferences("machine_no", MODE_PRIVATE);

    if (!Tools.isNull(App.getMachineNo(mContext))) {
      startActivity(new Intent(mContext, MainAc.class));
    }
  }
예제 #2
0
  /** 按键事件监听 */
  public boolean onKeyDown(int keyCode, android.view.KeyEvent event) {
    switch (keyCode) {
      case KeyEvent.KEYCODE_TAB:
        //        date=tv_time.getText().toString();
        String machine = et_input.getText().toString();
        if (!Tools.isNull(machine)) {
          Editor ed = sp_machine_no.edit();
          ed.clear();
          ed.putString("no", machine);
          ed.commit();
          startActivity(new Intent(mContext, MainAc.class));
        } else {
          Toast.makeText(mContext, "请输入机台号", Toast.LENGTH_LONG);
        }
        break;

      default:
        break;
    }
    return super.onKeyDown(keyCode, event);
  }