package com.example.test1;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;
public class MainActivity extends Activity implements OnClickListener{
/** Called when the activity is first created. */
//private static final String PREFS_NAME = "MyInfo";//用来保存用户信息
public static EditText Num,Pwd;
private static Button Login,Post,pwdback;
//public static CheckBox RememberPwd,AutoLogin;
private DBHelper dbHelper;
public static SQLiteDatabase sdb;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// AppConnect.getInstance(this);
// LinearLayout container =(LinearLayout)findViewById(R.id.AdLinearLayout);
// new AdView(this,container).DisplayAd();
//获得实例对象
Num=(EditText) findViewById(R.id.et_Num);
Pwd=(EditText) findViewById(R.id.et_Pwd);
Login=(Button) findViewById(R.id.btn_Login);
Post=(Button) findViewById(R.id.Post);
pwdback = (Button) findViewById(R.id.pwdback);
Post.setOnClickListener(this);
Login.setOnClickListener(this);
pwdback.setOnClickListener(this);
dbHelper=new DBHelper(this,"Info.db");
//LoadUserDate();
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()){
case R.id.btn_Login:
if(Num.getText().toString().equals("")){
Toast.makeText(MainActivity.this,"姓名不能为空 ", Toast.LENGTH_SHORT).show();
return;
}
if(Pwd.getText().toString().equals("")){
Toast.makeText(MainActivity.this,"号码不能为空 ", Toast.LENGTH_SHORT).show();
return;
}
//SaveUserDate();
boolean bool=login(Num.getText().toString(),Pwd.getText().toString());
if(bool){
Toast.makeText(MainActivity.this, "登录成功!", Toast.LENGTH_LONG).show();
Intent intent = new Intent();
intent.putExtra("name",Num.getText().toString());
intent.setClass(MainActivity.this, AfterLogin.class);
MainActivity.this.startActivity(intent);
}else{
Toast.makeText(MainActivity.this, "用户名或密码有误!", Toast.LENGTH_LONG).show();
return;
}
break;
case R.id.Post:
Intent intent=new Intent(MainActivity.this,Register.class);
startActivity(intent);
break;
case R.id.pwdback:
//System.out.println("被响应");
Intent intent1 = new Intent();
//intent.putExtra("name",Num.getText().toString());
intent1.setClass(MainActivity.this, pwdback.class);
MainActivity.this.startActivity(intent1);
break;
}
}
//登录
public boolean login(String username,String password){
String name = new Security().Encryption(username);
String pwd = new Security().Encryption(password);
/*SQLiteDatabase*/ sdb=dbHelper.getReadableDatabase();
String sql="select * from people where name=? and pwd=?";
Cursor cursor=sdb.rawQuery(sql, new String[]{name,pwd});
if(cursor.moveToFirst()==true){
cursor.close();
return true;
}
return false;
}
//退出
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK ) {
AlertDialog.Builder builder = new Builder(MainActivity.this);
builder.setIcon(android.R.drawable.ic_dialog_info);
builder.setMessage("确定要退出?");
builder.setTitle("提示");
builder.setPositiveButton("确认",
new android.content.DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
MainActivity.this.finish();
}
});
builder.setNegativeButton("取消",
new android.content.DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}
return false;
}
// /**
// * 保存用户信息
// */
// private void SaveUserDate() {
// // 载入配置文件
// SharedPreferences sp = getSharedPreferences(PREFS_NAME, 0);
// // 写入配置文件
// Editor spEd = sp.edit();
// if (RememberPwd.isChecked()) {
// spEd.putBoolean("isSave", true);
// spEd.putString("name", Num.getText().toString());
// spEd.putString("password", Pwd.getText().toString());
// } else {
// spEd.putBoolean("isSave", false);
// spEd.putString("name", "");
// spEd.putString("password", "");
// }
// spEd.commit();
// }
//
// /**
// * 载入已记住的用户信息
// */
// private void LoadUserDate() {
// SharedPreferences sp = getSharedPreferences(PREFS_NAME, 0);
//
// if (sp.getBoolean("isSave", false)) {
// String username = sp.getString("name", "");
// String userpassword = sp.getString("password", "");
// if (!("".equals(username) && "".equals(userpassword))) {
// Num.setText(username);
// Pwd.setText(userpassword);
// RememberPwd.setChecked(true);
// }
// }
// }
}
资源文件列表
test1/.classpath , 491
test1/.project , 841
test1/.settings/org.eclipse.jdt.core.prefs , 177
test1/AndroidManifest.xml , 1295
test1/bin/AndroidManifest.xml , 1295
test1/bin/classes.dex , 726240
test1/bin/classes/com/example/test1/AfterLogin.class , 2741
test1/bin/classes/com/example/test1/BuildConfig.class , 343
test1/bin/classes/com/example/test1/DBHelper.class , 3012
test1/bin/classes/com/example/test1/Limit.class , 4918
test1/bin/classes/com/example/test1/MAC.class , 3134
test1/bin/classes/com/example/test1/MACAdapter.class , 1743
test1/bin/classes/com/example/test1/MainActivity$1.class , 914
test1/bin/classes/com/example/test1/MainActivity$2.class , 884
test1/bin/classes/com/example/test1/MainActivity.class , 4882
test1/bin/classes/com/example/test1/ManageGrade.class , 3854
test1/bin/classes/com/example/test1/MyAdapter.class , 2738
test1/bin/classes/com/example/test1/pwdback.class , 4476
test1/bin/classes/com/example/test1/R$anim.class , 473
test1/bin/classes/com/example/test1/R$attr.class , 337
test1/bin/classes/com/example/test1/R$drawable.class , 1610
test1/bin/classes/com/example/test1/R$id.class , 2219
test1/bin/classes/com/example/test1/R$layout.class , 609
test1/bin/classes/com/example/test1/R$string.class , 424
test1/bin/classes/com/example/test1/R$style.class , 467
test1/bin/classes/com/example/test1/R.class , 616
test1/bin/classes/com/example/test1/Register$1.class , 1137
test1/bin/classes/com/example/test1/Register$2.class , 3863
test1/bin/classes/com/example/test1/Register.class , 3829
test1/bin/classes/com/example/test1/Security.class , 1285
test1/bin/classes/com/example/test1/share.class , 5790
test1/bin/dexedLibs/android-support-v4-0db5facc12b46fc2ca4ed26c3bb50a73.jar , 232610
test1/bin/dexedLibs/annotations-c5d1844c2c6a1f6b823f77032eed1843.jar , 943
test1/bin/dexedLibs/AppOffer_2.0.0-b2cfd6ba7bbc5965aab5fa363c3b933c.jar , 66320
test1/bin/jarlist.cache , 120
test1/bin/resources.ap_ , 65200
test1/bin/res/crunch/drawable-hdpi/app_icon.png , 9923
test1/bin/res/crunch/drawable-hdpi/btn_style_alert_dialog_background.9.png , 1127
test1/bin/res/crunch/drawable-hdpi/btn_style_alert_dialog_button_normal.9.png , 1458
test1/bin/res/crunch/drawable-hdpi/btn_style_alert_dialog_button_pressed.9.png , 1445
test1/bin/res/crunch/drawable-hdpi/btn_style_alert_dialog_cancel_normal.9.png , 1385
test1/bin/res/crunch/drawable-hdpi/btn_style_alert_dialog_special_normal.9.png , 1412
test1/bin/res/crunch/drawable-hdpi/btn_style_alert_dialog_special_pressed.9.png , 1382
test1/bin/res/crunch/drawable-hdpi/checkbox_selected.png , 556
test1/bin/res/crunch/drawable-hdpi/checkbox_selected_press.png , 570
test1/bin/res/crunch/drawable-hdpi/checkbox_unselect.png , 471
test1/bin/res/crunch/drawable-hdpi/checkbox_unselect_press.png , 464
test1/bin/res/crunch/drawable-hdpi/divider_horizontal_line.png , 241
test1/bin/res/crunch/drawable-hdpi/ic_launcher.png , 3966
test1/bin/res/crunch/drawable-hdpi/login_button_nor.9.png , 768
test1/bin/res/crunch/drawable-hdpi/login_button_press.9.png , 759
test1/bin/res/crunch/drawable-hdpi/login_input.9.png , 612
test1/bin/res/crunch/drawable-hdpi/login_input_arrow.png , 225
test1/bin/res/crunch/drawable-hdpi/login_input_arrow1.png , 221
test1/bin/res/crunch/drawable-ldpi/ic_launcher.png , 1537
test1/bin/res/crunch/drawable-mdpi/ic_launcher.png , 2200
test1/bin/test1.apk , 315159
test1/gen/com/example/test1/BuildConfig.java , 159
test1/gen/com/example/test1/R.java , 6508
test1/ic_launcher-web.png , 51394
test1/libs/android-support-v4.jar , 621451
test1/proguard-project.txt , 781
test1/project.properties , 563
test1/res/anim/push_bottom_in.xml , 278
test1/res/anim/push_bottom_in2.xml , 277
test1/res/anim/push_bottom_out.xml , 263
test1/res/drawable-hdpi/app_icon.png , 12642
test1/res/drawable-hdpi/btn_style_alert_dialog_background.9.png , 997
test1/res/drawable-hdpi/btn_style_alert_dialog_button_normal.9.png , 1447
test1/res/drawable-hdpi/btn_style_alert_dialog_button_pressed.9.png , 1366
test1/res/drawable-hdpi/btn_style_alert_dialog_cancel_normal.9.png , 1429
test1/res/drawable-hdpi/btn_style_alert_dialog_special_normal.9.png , 1321
test1/res/drawable-hdpi/btn_style_alert_dialog_special_pressed.9.png , 1313
test1/res/drawable-hdpi/checkbox_selected.png , 556
test1/res/drawable-hdpi/checkbox_selected_press.png , 570
test1/res/drawable-hdpi/checkbox_unselect.png , 471
test1/res/drawable-hdpi/checkbox_unselect_press.png , 464
test1/res/drawable-hdpi/divider_horizontal_line.png , 3057
test1/res/drawable-hdpi/ic_launcher.png , 4147
test1/res/drawable-hdpi/login_button_nor.9.png , 940
test1/res/drawable-hdpi/login_button_press.9.png , 938
test1/res/drawable-hdpi/login_input.9.png , 453
test1/res/drawable-hdpi/login_input_arrow.png , 225
test1/res/drawable-hdpi/login_input_arrow1.png , 221
test1/res/drawable-hdpi/login_reg_normal.9.png , 895
test1/res/drawable-hdpi/login_reg_pressed.9.png , 900
test1/res/drawable-hdpi/logo_bg.jpg , 9196
test1/res/drawable-ldpi/ic_launcher.png , 1723
test1/res/drawable-mdpi/ic_launcher.png , 2574
test1/res/drawable/btn_style_alert_dialog_button.xml , 315
test1/res/drawable/btn_style_alert_dialog_cancel.xml , 316
test1/res/drawable/btn_style_alert_dialog_special.xml , 317
test1/res/drawable/checkbox_bg.xml , 785
test1/res/drawable/login_button_select.xml , 423
test1/res/drawable/login_reg_button.xml , 306
test1/res/layout/afterlogin.xml , 1745
test1/res/layout/limit.xml , 2161
test1/res/layout/mac.xml , 1552
test1/res/layout/main.xml , 3699
test1/res/layout/managegreade.xml , 2958
test1/res/layout/pwdback.xml , 3429
test1/res/layout/register.xml , 4378
test1/res/layout/share.xml , 1563
test1/res/values/strings.xml , 185
test1/res/values/styles.xml , 1050
test1/src/com/example/test1/AfterLogin.java , 2180
test1/src/com/example/test1/DBHelper.java , 3151
test1/src/com/example/test1/Limit.java , 4574
test1/src/com/example/test1/MAC.java , 2037
test1/src/com/example/test1/MACAdapter.java , 849
test1/src/com/example/test1/MainActivity.java , 5887
test1/src/com/example/test1/ManageGrade.java , 2661
test1/src/com/example/test1/MyAdapter.java , 2095
test1/src/com/example/test1/pwdback.java , 3169
test1/src/com/example/test1/Register.java , 4264
test1/src/com/example/test1/Security.java , 965
test1/src/com/example/test1/share.java , 4487
