基于Android的个人健康APP软件设计与开发 - 论文 下载本文

毕业设计

package com.mm.HealthyApp.activity;

import java.sql.SQLException;

32

附 毕业设计

import android.os.Bundle; import android.view.View;

import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.TextView;

import com.j256.ormlite.dao.Dao; import com.miebo.utils.BaseActivity; import com.miebo.utils.BaseUtil; import com.miebo.utils.ToastUtil;

import com.mm.HealthyApp.api.DBTable_User; import com.mm.HealthyApp.db.OrmDatabaseHelper;

public class UpdatePwdActivity extends BaseActivity {

private void findview() {

((TextView) findViewById(R.id.tvTopTitleCenter)).setText(\修改密码\@Override

public void onCreate(Bundle savedInstanceState) { }

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_updatepwd); toastUtil = new ToastUtil(getApplicationContext()); orm = new OrmDatabaseHelper(getApplicationContext()); findview();

btnRegister.setOnClickListener(new btnRegisterOnClickListener()); private ToastUtil toastUtil; private Button btnRegister;

private EditText etPassword, etPasswordOK; private OrmDatabaseHelper orm;

33

毕业设计

}

btnRegister = (Button) findViewById(R.id.btnRegister); etPassword = (EditText) findViewById(R.id.etPassword); etPasswordOK = (EditText) findViewById(R.id.etPasswordOK);

private class btnRegisterOnClickListener implements OnClickListener {

@Override

public void onClick(View v) {

if (etPassword.getText().length() == 0) { }

if (etPassword.getText().length() < 6) { }

if (etPasswordOK.getText().length() == 0) { }

if (!etPasswordOK.getText().toString().equals(etPassword.getText().toString())) { }

BaseUtil.HideKeyboard(UpdatePwdActivity.this);

Dao dao = orm.getDBTable_UserDao(); try {

DBTable_User model = dao.queryForId(user.getId()); model.setPassword(etPasswordOK.getText().toString()); dao.create(model);

toastUtil.show(\修改成功\

toastUtil.show(\两次输入密码不一致\return;

toastUtil.show(\请再次输入密码\return;

toastUtil.show(\密码长度至少为6位\return;

toastUtil.show(\请输入密码\return;

} catch (SQLException e) {

e.printStackTrace();

34

毕业设计

}

};

}

}

35