今天进行
登陆界面界面设置
代码:RiqiActivity.java
1 package com.anoic.lvbook; 2 3 4 import android.app.Activity; 5 import android.view.KeyEvent; 6 7 public interface RiqiActivity { 8 9 static final String [] months={"Jan.","Feb.","Ma.r","Apr.","May.","Jun.","Jul.","Aug.","Sept.","Oct.","Nov.","Dec."}; 10 static final String [] months_zh={"一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"}; 11 static final String [] menu_toolbars_name={"首页","添加","删除","关于","菜单"}; 12 }
Lvsbook.java
1 package com.anoic.AccoutBook; 2 3 import java.util.Calendar; 4 import java.util.Locale; 5 import java.util.Timer; 6 import java.util.TimerTask; 7 8 import android.app.Activity; 9 import android.content.Intent; 10 import android.content.SharedPreferences; 11 import android.graphics.Color; 12 import android.graphics.Typeface; 13 import android.os.Bundle; 14 import android.util.Log; 15 import android.view.ContextMenu; 16 import android.view.KeyEvent; 17 import android.view.View; 18 import android.view.ContextMenu.ContextMenuInfo; 19 import android.view.View.OnClickListener; 20 import android.widget.Button; 21 import android.widget.CheckBox; 22 import android.widget.EditText; 23 import android.widget.TextView; 24 25 import android.widget.Toast; 26 27 28 public class AccountsBook extends Activity implements AbstractActivity { 29 /** Called when the activity is first created. */ 30 private static Boolean isExit= false; 31 private static Boolean hasTask = false; 32 Timer tExit = new Timer(); 33 private EditText meditText,mpassword; 34 private TextView mtvyear,mtvpass; 35 private Button mEnterButton,mSetPassButton,mClearButton; 36 private CheckBox mCheckBox; 37 public static final String CONFIG_NAME = "accountsbook"; 38 Calendar c = Calendar.getInstance(Locale.CHINA); 39 private SharedPreferences mPreferences; 40 41 @Override 42 public void onCreate(Bundle savedInstanceState) { 43 super.onCreate(savedInstanceState); 44 setContentView(R.layout.main); 45 initUI(); 46 } 47 48 //初始化 49 public void initUI(){ 50 51 mPreferences = getSharedPreferences(CONFIG_NAME, AccountsBook.MODE_WORLD_READABLE); 52 53 mtvyear = (TextView) findViewById(R.id.tvyear); 54 mtvpass = (TextView) findViewById(R.id.tvpass); 55 mSetPassButton = (Button)findViewById(R.id.setpass); 56 mClearButton = (Button)findViewById(R.id.clearall); 57 meditText = (EditText) findViewById(R.id.setmonth); 58 mpassword = (EditText) findViewById(R.id.password); 59 mEnterButton = (Button) findViewById(R.id.enter); 60 mCheckBox = (CheckBox) findViewById(R.id.isRempass); 61 62 63 64 mtvyear.setText("年份:"); 65 mtvpass.setText("密码:"); 66 mtvyear.setTypeface(Typeface.DEFAULT_BOLD); 67 mtvpass.setTypeface(Typeface.DEFAULT_BOLD); 68 mtvyear.setTextColor(Color.WHITE); 69 mtvpass.setTextColor(Color.WHITE); 70 meditText.setText(c.get(Calendar.YEAR)+""); 71 72 73 //设置密码监听 74 mSetPassButton.setOnClickListener(new OnClickListener() { 75 76 @Override 77 public void onClick(View v) { 78 // TODO Auto-generated method stub 79 Intent intent = new Intent(); 80 Bundle b = new Bundle(); 81 b.putString("year",meditText.getText().toString()); 82 intent.putExtras(b); 83 intent.setClass(AccountsBook.this,SetPassActivity.class); 84 startActivity(intent); 85 } 86 }); 87 88 //进入按钮监听器 89 mEnterButton.setOnClickListener(new OnClickListener() { 90 boolean isenter = false; 91 @Override 92 public void onClick(View v) { 93 // TODO Auto-generated method stub 94 if("".equals(meditText.getText().toString())){ 95 Toast.makeText(AccountsBook.this, "请选择年份",Toast.LENGTH_LONG).show(); 96 return; 97 } 98 if(mPreferences.getBoolean("issetpass", false)){ 99 if("".equals(mpassword.getText().toString())){ 100 Toast.makeText(AccountsBook.this, "请输入密码",Toast.LENGTH_LONG).show(); 101 return ; 102 }else{ 103 // Log.e("",) 104 isenter = (mPreferences.getString("password","").equals(mpassword.getText().toString()))?true:false; 105 if(!isenter){ 106 Toast.makeText(AccountsBook.this, "密码不正确",Toast.LENGTH_LONG).show(); 107 return ; 108 } 109 } 110 } 111 112 if(isenter){ 113 Intent intent = new Intent(); 114 Bundle b = new Bundle(); 115 b.putString("year",meditText.getText().toString()); 116 intent.putExtras(b); 117 intent.setClass(AccountsBook.this,MonthGridActivity.class); 118 startActivity(intent); 119 }else{ 120 return ; 121 } 122 } 123 }); 124 125 //个性化设置操作记录 126 127 if(mPreferences.getBoolean("isfirst",true)){ 128 Toast.makeText(AccountsBook.this,"您第一次登录本系统,为了您的隐私安全,请设置访问密码!",Toast.LENGTH_LONG).show(); 129 } 130 if(mPreferences.getBoolean("isRempass",false)){ 131 mpassword.setText(mPreferences.getString("password","")); 132 mCheckBox.setChecked(true); 133 } 134 } 135 136 137
遇到问题:设置密码无法应用,重置。
明天:继续密码设置。