2.5日 Andriod 记账本开发
//点击眼睛时,如果是明文就加密,如果是密文,就变成明文
private void toggleShow() {
if (isShow) {
PasswordTransformationMethod passwordMethod = PasswordTransformationMethod.getInstance();
topInTv.setTransformationMethod(passwordMethod);
topOutTv.setTransformationMethod(passwordMethod);
topbudgetTv.setTransformationMethod(passwordMethod);
topShowIv.setImageResource(R.mipmap.ih_hide);
isShow = false;
} else {
HideReturnsTransformationMethod hideReturnsTransformationMethod = HideReturnsTransformationMethod.getInstance();
topInTv.setTransformationMethod(hideReturnsTransformationMethod);
topOutTv.setTransformationMethod(hideReturnsTransformationMethod);
topbudgetTv.setTransformationMethod(hideReturnsTransformationMethod);
topShowIv.setImageResource(R.mipmap.ih_show);
isShow = true;
}
}
private void toggleShow() {
if (isShow) {
PasswordTransformationMethod passwordMethod = PasswordTransformationMethod.getInstance();
topInTv.setTransformationMethod(passwordMethod);
topOutTv.setTransformationMethod(passwordMethod);
topbudgetTv.setTransformationMethod(passwordMethod);
topShowIv.setImageResource(R.mipmap.ih_hide);
isShow = false;
} else {
HideReturnsTransformationMethod hideReturnsTransformationMethod = HideReturnsTransformationMethod.getInstance();
topInTv.setTransformationMethod(hideReturnsTransformationMethod);
topOutTv.setTransformationMethod(hideReturnsTransformationMethod);
topbudgetTv.setTransformationMethod(hideReturnsTransformationMethod);
topShowIv.setImageResource(R.mipmap.ih_show);
isShow = true;
}
}
private void showBudgetDialog() {
//显示设置预算对话框
BudgetDialog dialog = new BudgetDialog(this);
dialog.show();
dialog.setOnEnsureListener(money -> {
//将金额写入共享参数中,进行存储
SharedPreferences.Editor editor = preferences.edit();
editor.putFloat("bmoney", money);
editor.commit();
//计算剩余金额
float outComeMonth = DBManager.getMoneyOneMonth(year, month, 0);
float sMoney = money - outComeMonth;//预算剩余
topbudgetTv.setText("¥ " + sMoney);
});
}
//显示设置预算对话框
BudgetDialog dialog = new BudgetDialog(this);
dialog.show();
dialog.setOnEnsureListener(money -> {
//将金额写入共享参数中,进行存储
SharedPreferences.Editor editor = preferences.edit();
editor.putFloat("bmoney", money);
editor.commit();
//计算剩余金额
float outComeMonth = DBManager.getMoneyOneMonth(year, month, 0);
float sMoney = money - outComeMonth;//预算剩余
topbudgetTv.setText("¥ " + sMoney);
});
}