【Android Sqlite】萌动的sqlite数据库,简单实现:用户增删改查

前端之家收集整理的这篇文章主要介绍了【Android Sqlite】萌动的sqlite数据库,简单实现:用户增删改查前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

sqlite数据的使用很常见呢,我们简单学习一下app的登录注册修改删除用户吧!@H_404_2@

下面就写一个萌动的app注册登录吧!@H_404_2@


@H_404_2@

页面:@H_404_2@@H_404_2@

还有2个图片按钮(虽然不是很好看,但是将就吧→。→)@H_404_2@


@H_404_2@



EditView输入框的监听事件,2张图片的切换@H_404_2@

(为了找22,33的图片,我反编译了 bilibii 的app,想不到图片是分为4张的 →。→)@H_404_2@


用户注册:@H_404_2@



修改密码:这里的判断比较多!@H_404_2@



删除:@H_404_2@


代码构成一览:@H_404_2@




一、entity:User 实体类@H_404_2@

自己写 →。→@H_404_2@

private int @H_404_2@id@H_404_2@;
@H_404_2@private @H_404_2@String uname@H_404_2@;
@H_404_2@private @H_404_2@String upwd@H_404_2@;
@H_404_2@private int @H_404_2@isDel@H_404_2@;@H_404_2@

二、dao包:@H_404_2@

DBOpenHelper:建表@H_404_2@


package @H_404_2@example.com.user_sqlite.dao;
@H_404_2@
@H_404_2@import @H_404_2@android.content.Context;
@H_404_2@import @H_404_2@android.database.sqlite.sqliteDatabase;
@H_404_2@import @H_404_2@android.database.sqlite.sqliteDatabase.CursorFactory;
@H_404_2@import @H_404_2@android.database.sqlite.sqliteOpenHelper;
@H_404_2@
@H_404_2@/** @H_404_2@ * Created by Administrator on 2017/4/5. @H_404_2@ */ @H_404_2@public class @H_404_2@DBOpenHelper extends @H_404_2@sqliteOpenHelper{

    public @H_404_2@DBOpenHelper(Context context,@H_404_2@String name,@H_404_2@CursorFactory factory,int @H_404_2@version) {
        super@H_404_2@(context,@H_404_2@"sqliteTest.db"@H_404_2@,null,@H_404_2@1@H_404_2@);
@H_404_2@    @H_404_2@}

    @Override
@H_404_2@    @H_404_2@public void @H_404_2@onCreate@H_404_2@(sqliteDatabase sqliteDatabase) {
        String sql=
                "create table if not exists t_user("@H_404_2@+
                        "id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,"@H_404_2@+
                        "uname VARCHAR(255),"@H_404_2@+
                        "upwd VARCHAR(255),"@H_404_2@+
                        "isDel INTEGER DEFAULT 0"@H_404_2@+
                        ")"@H_404_2@;
@H_404_2@        @H_404_2@sqliteDatabase.execsql(sql);
@H_404_2@    @H_404_2@}

    @Override
@H_404_2@    @H_404_2@public void @H_404_2@onUpgrade@H_404_2@(sqliteDatabase arg0,int @H_404_2@arg1,int @H_404_2@arg2) {
    }

}

UserDao:sql语句的编写@H_404_2@


package @H_404_2@example.com.user_sqlite.dao;
@H_404_2@
@H_404_2@import @H_404_2@android.content.Context;
@H_404_2@import @H_404_2@android.database.Cursor;
@H_404_2@import @H_404_2@android.database.sqlite.sqliteDatabase;
@H_404_2@import @H_404_2@java.lang.reflect.Array;
@H_404_2@import @H_404_2@java.util.ArrayList;
@H_404_2@
@H_404_2@import @H_404_2@example.com.user_sqlite.entity.User;
@H_404_2@
@H_404_2@/** @H_404_2@ * Created by Administrator on 2017/3/19. @H_404_2@ */ @H_404_2@public class @H_404_2@UserDao {
    private @H_404_2@DBOpenHelper dbOpenHelper@H_404_2@;      @H_404_2@//创建DBOpenHelper对象
@H_404_2@    @H_404_2@private @H_404_2@sqliteDatabase sqliteDatabase@H_404_2@; @H_404_2@//创建sqliteDatabase对象
@H_404_2@    @H_404_2@public @H_404_2@UserDao(Context context){       //定义构造函数
@H_404_2@        @H_404_2@dbOpenHelper@H_404_2@=new @H_404_2@DBOpenHelper(context,@H_404_2@0@H_404_2@);  @H_404_2@//初始化DBOpenHelper对象
@H_404_2@    @H_404_2@}
//插入数据
@H_404_2@    @H_404_2@public void @H_404_2@dbInsert@H_404_2@(String uname,@H_404_2@String upwd){
        sqliteDatabase @H_404_2@=dbOpenHelper@H_404_2@.getWritableDatabase();
@H_404_2@        @H_404_2@String sql="insert into t_user(uname,upwd,isDel) values (?,?,0)"@H_404_2@;
@H_404_2@        @H_404_2@Object bindArgs[] = new @H_404_2@Object[]{ uname,@H_404_2@upwd};
@H_404_2@        @H_404_2@sqliteDatabase@H_404_2@.execsql(sql,@H_404_2@bindArgs);
@H_404_2@    @H_404_2@}
//查询数据
@H_404_2@    @H_404_2@public int @H_404_2@dbGetUserSize@H_404_2@(){
        sqliteDatabase @H_404_2@= dbOpenHelper@H_404_2@.getWritableDatabase();
@H_404_2@        @H_404_2@String sql="select count(*) from t_user where isDel=0"@H_404_2@;
@H_404_2@        @H_404_2@Cursor cursor = sqliteDatabase@H_404_2@.rawQuery(sql,null@H_404_2@);
@H_404_2@        if @H_404_2@(cursor.moveToNext())       //判断Cursor中是否有数据
@H_404_2@        @H_404_2@{
            return @H_404_2@cursor.getInt(0@H_404_2@);  @H_404_2@//返回总记录数
@H_404_2@        @H_404_2@}
        return @H_404_2@0@H_404_2@;                     @H_404_2@//如果没有数据,则返回0
@H_404_2@    @H_404_2@}

    public @H_404_2@User dbQueryOneByUsername@H_404_2@(String uname){
        sqliteDatabase @H_404_2@= dbOpenHelper@H_404_2@.getWritableDatabase();
@H_404_2@        @H_404_2@String sql="select * from t_user where uname=? and isDel=0"@H_404_2@;
@H_404_2@        @H_404_2@String[] selectionArgs = new @H_404_2@String[]{ uname };
@H_404_2@        @H_404_2@Cursor cursor = sqliteDatabase@H_404_2@.rawQuery(sql,@H_404_2@selectionArgs);
@H_404_2@        if @H_404_2@(cursor.moveToNext())  //判断Cursor中是否有数据
@H_404_2@        @H_404_2@{
            User user=new @H_404_2@User();
@H_404_2@            @H_404_2@user.setId(cursor.getInt(cursor.getColumnIndex("id"@H_404_2@)));
@H_404_2@            @H_404_2@user.setUname(cursor.getString(cursor.getColumnIndex("uname"@H_404_2@)));
@H_404_2@            @H_404_2@user.setUpwd(cursor.getString(cursor.getColumnIndex("upwd"@H_404_2@)));
@H_404_2@            return @H_404_2@user; @H_404_2@//返回总记录行数
@H_404_2@        @H_404_2@}
        return null;
@H_404_2@    @H_404_2@}
//修改密码
@H_404_2@    @H_404_2@public void @H_404_2@dbUpdatePassword@H_404_2@(String uname,@H_404_2@String newUpwd){
        sqliteDatabase @H_404_2@= dbOpenHelper@H_404_2@.getWritableDatabase();
@H_404_2@        @H_404_2@String sql="update t_user set upwd=? where uname=? and isDel=0"@H_404_2@;
@H_404_2@        @H_404_2@Object bindArgs[] = new @H_404_2@Object[]{ newUpwd,@H_404_2@uname };
@H_404_2@        @H_404_2@sqliteDatabase@H_404_2@.execsql(sql,@H_404_2@bindArgs);
@H_404_2@    @H_404_2@}
//查询新增数
@H_404_2@    @H_404_2@public @H_404_2@ArrayList<User> dbQueryAll@H_404_2@(){
        ArrayList<User> userArrayList = new @H_404_2@ArrayList<User>();
@H_404_2@        @H_404_2@sqliteDatabase @H_404_2@= dbOpenHelper@H_404_2@.getWritableDatabase();
@H_404_2@        @H_404_2@String sql="select * from t_user where isDel=0"@H_404_2@;
@H_404_2@        @H_404_2@Cursor cursor= sqliteDatabase@H_404_2@.rawQuery(sql,null@H_404_2@);
@H_404_2@        for @H_404_2@(cursor.moveToFirst(); @H_404_2@!(cursor.isAfterLast()); @H_404_2@cursor.moveToNext()){
            if @H_404_2@(cursor.getInt(cursor.getColumnIndex("isDel"@H_404_2@))!=1@H_404_2@){
                User user=new @H_404_2@User();
@H_404_2@                @H_404_2@user.setId(cursor.getInt(cursor.getColumnIndex("id"@H_404_2@)));
@H_404_2@                @H_404_2@user.setUname(cursor.getString(cursor.getColumnIndex("uname"@H_404_2@)));
@H_404_2@                @H_404_2@user.setUpwd(cursor.getString(cursor.getColumnIndex("upwd"@H_404_2@)));
@H_404_2@                @H_404_2@userArrayList.add(user);
@H_404_2@            @H_404_2@}
        }
        return @H_404_2@userArrayList;
@H_404_2@    @H_404_2@}

//更新数据
@H_404_2@    @H_404_2@public void @H_404_2@dbDeleteUser@H_404_2@(int @H_404_2@id){
        sqliteDatabase @H_404_2@= dbOpenHelper@H_404_2@.getWritableDatabase();
@H_404_2@        @H_404_2@String sql="update t_user set isDel=1 where id=?"@H_404_2@;
@H_404_2@        @H_404_2@Object bindArgs[] = new @H_404_2@Object[]{ id };
@H_404_2@        @H_404_2@sqliteDatabase@H_404_2@.execsql(sql,@H_404_2@bindArgs);
@H_404_2@    @H_404_2@}

}

三、实现的方法:@H_404_2@

1、MainActivity@H_404_2@


package @H_404_2@example.com.user_sqlite;
@H_404_2@
@H_404_2@import @H_404_2@android.os.Bundle;
@H_404_2@import @H_404_2@android.view.View;
@H_404_2@import @H_404_2@android.view.View.OnClickListener;
@H_404_2@import @H_404_2@android.widget.Button;
@H_404_2@import @H_404_2@android.widget.EditText;
@H_404_2@import @H_404_2@android.widget.ImageView;
@H_404_2@import @H_404_2@android.widget.Toast;
@H_404_2@import @H_404_2@android.app.Activity;
@H_404_2@import @H_404_2@android.content.Intent;
@H_404_2@
@H_404_2@import @H_404_2@example.com.user_sqlite.dao.UserDao;
@H_404_2@import @H_404_2@example.com.user_sqlite.entity.User;
@H_404_2@
@H_404_2@public class @H_404_2@MainActivity extends @H_404_2@Activity {
    private @H_404_2@ImageView bili1@H_404_2@,@H_404_2@bili2@H_404_2@;
@H_404_2@// 用户登录
@H_404_2@    @H_404_2@private @H_404_2@EditText editTextA1@H_404_2@;
@H_404_2@    private @H_404_2@EditText editTextA2@H_404_2@;
@H_404_2@    private @H_404_2@Button buttonA1@H_404_2@;
@H_404_2@
@H_404_2@    @H_404_2@// 数据库操作类
@H_404_2@    @H_404_2@private @H_404_2@UserDao userDao@H_404_2@;
@H_404_2@
@H_404_2@    @H_404_2@@Override
@H_404_2@    @H_404_2@protected void @H_404_2@onCreate@H_404_2@(Bundle savedInstanceState) {
        super@H_404_2@.onCreate(savedInstanceState);
@H_404_2@        @H_404_2@setContentView(R.layout.activity_main);
@H_404_2@
@H_404_2@// 注册组件
@H_404_2@        @H_404_2@userDao = new @H_404_2@UserDao(this@H_404_2@);
@H_404_2@        @H_404_2@editTextA1 = (EditText) findViewById(R.id.editTextA1);
@H_404_2@        @H_404_2@editTextA2 = (EditText) findViewById(R.id.editTextA2);
@H_404_2@
@H_404_2@        @H_404_2@buttonA1 = (Button) findViewById(R.id.buttonA1);
@H_404_2@        @H_404_2@bili1=(ImageView) findViewById(R.id.bili1);
@H_404_2@        @H_404_2@bili2=(ImageView) findViewById(R.id.bili2);
@H_404_2@
@H_404_2@// 用户登录
@H_404_2@        @H_404_2@buttonA1.setOnClickListener(new @H_404_2@OnClickListener() {
            @Override
            public void @H_404_2@onClick(View v) {
                String uname = editTextA1.getText() + ""@H_404_2@;
@H_404_2@                @H_404_2@String upwd = editTextA2.getText() + ""@H_404_2@;
@H_404_2@//一个是输入不能为空,一个是不能只打空格null
@H_404_2@                @H_404_2@if @H_404_2@(uname.equals(null@H_404_2@) || uname == "" @H_404_2@|| upwd.equals(null@H_404_2@) || upwd == ""@H_404_2@) {
                    Toast.makeText(MainActivity.this,@H_404_2@"用户名或密码不得为空!"@H_404_2@,@H_404_2@Toast.LENGTH_SHORT).show();
@H_404_2@                @H_404_2@} else @H_404_2@{
                    User user = userDao.dbQueryOneByUsername(uname);
@H_404_2@                    if @H_404_2@(userDao.dbQueryOneByUsername(uname) == null@H_404_2@) {
                        Toast.makeText(MainActivity.this,@H_404_2@"此用户不存在!"@H_404_2@,@H_404_2@Toast.LENGTH_SHORT).show();
@H_404_2@                    @H_404_2@} else @H_404_2@{
                        if @H_404_2@(!user.getUpwd().equals(upwd)) {
                            Toast.makeText(MainActivity.this,@H_404_2@"密码错误!"@H_404_2@,@H_404_2@Toast.LENGTH_SHORT).show();
@H_404_2@                        @H_404_2@} else @H_404_2@{
                            Toast.makeText(MainActivity.this,@H_404_2@"登录成功!"@H_404_2@,@H_404_2@Toast.LENGTH_SHORT).show();
@H_404_2@                            @H_404_2@Intent intent = new @H_404_2@Intent(MainActivity.this,@H_404_2@TableActivity.class@H_404_2@);
@H_404_2@                            @H_404_2@startActivity(intent);
@H_404_2@                        @H_404_2@}
                    }
                }
            }
        });
@H_404_2@//输入框 获取/失去 焦点切换图片
@H_404_2@        @H_404_2@editTextA1@H_404_2@.setOnFocusChangeListener(new @H_404_2@android.view.View.OnFocusChangeListener(){

            @Override
@H_404_2@            @H_404_2@public void @H_404_2@onFocusChange@H_404_2@(View v,boolean @H_404_2@hasFocus) {
            //获取焦点的时候,图片显示图片二隐藏
@H_404_2@                @H_404_2@if @H_404_2@(hasFocus){
                    bili1@H_404_2@.setVisibility(v.VISIBLE@H_404_2@);
@H_404_2@                    @H_404_2@bili2@H_404_2@.setVisibility(v.GONE@H_404_2@);
@H_404_2@                @H_404_2@}else @H_404_2@{
                    bili2@H_404_2@.setVisibility(v.VISIBLE@H_404_2@);
@H_404_2@                    @H_404_2@bili1@H_404_2@.setVisibility(v.GONE@H_404_2@);
@H_404_2@                @H_404_2@}
            }
        });
@H_404_2@
@H_404_2@    @H_404_2@}
//注册
@H_404_2@    @H_404_2@public void @H_404_2@Login@H_404_2@(View view){
        Intent intent =  new @H_404_2@Intent(this,@H_404_2@LoginActivity.class@H_404_2@);
@H_404_2@        @H_404_2@startActivity(intent);
@H_404_2@    @H_404_2@}
//查看列表信息
@H_404_2@    @H_404_2@public void @H_404_2@Look(View view){
        Intent intent =  new @H_404_2@Intent(this,@H_404_2@TableActivity.class@H_404_2@);
@H_404_2@        @H_404_2@startActivity(intent);
@H_404_2@    @H_404_2@}
}

1.1:activity_main.xml@H_404_2@


<?@H_404_2@xml version=@H_404_2@"1.0" @H_404_2@encoding=@H_404_2@"utf-8"@H_404_2@?>
@H_404_2@<ScrollView @H_404_2@xmlns:@H_404_2@android@H_404_2@=@H_404_2@"http://schemas.android.com/apk/res/android"
@H_404_2@    @H_404_2@xmlns:@H_404_2@tools@H_404_2@=@H_404_2@"http://schemas.android.com/tools"
@H_404_2@    @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@    @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@    @H_404_2@android@H_404_2@:padding=@H_404_2@"10dp"
@H_404_2@    @H_404_2@android@H_404_2@:background=@H_404_2@"@android:color/white"
@H_404_2@    @H_404_2@tools@H_404_2@:context=@H_404_2@"example.com.user_sqlite.MainActivity"@H_404_2@>
@H_404_2@<LinearLayout
@H_404_2@    @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@    @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@    @H_404_2@android@H_404_2@:orientation=@H_404_2@"vertical"@H_404_2@>
@H_404_2@<!-- 用户登录: -->
@H_404_2@    @H_404_2@<ImageView
@H_404_2@        @H_404_2@android@H_404_2@:id=@H_404_2@"@+id/bili1"
@H_404_2@        @H_404_2@android@H_404_2@:layout_width=@H_404_2@"wrap_content"
@H_404_2@        @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@        @H_404_2@android@H_404_2@:src=@H_404_2@"@drawable/bi22"
@H_404_2@        @H_404_2@android@H_404_2@:layout_gravity=@H_404_2@"center_horizontal"@H_404_2@/>
@H_404_2@    <ImageView
@H_404_2@        @H_404_2@android@H_404_2@:id=@H_404_2@"@+id/bili2"
@H_404_2@        @H_404_2@android@H_404_2@:layout_width=@H_404_2@"wrap_content"
@H_404_2@        @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@        @H_404_2@android@H_404_2@:src=@H_404_2@"@drawable/bi33"
@H_404_2@        @H_404_2@android@H_404_2@:visibility=@H_404_2@"gone"
@H_404_2@        @H_404_2@android@H_404_2@:layout_gravity=@H_404_2@"center_horizontal"@H_404_2@/>
@H_404_2@<LinearLayout
@H_404_2@    @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@    @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@    @H_404_2@android@H_404_2@:orientation=@H_404_2@"vertical"
@H_404_2@    @H_404_2@android@H_404_2@:layout_marginTop=@H_404_2@"10dp"@H_404_2@>
@H_404_2@
@H_404_2@    <TextView
@H_404_2@        @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@        @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@        @H_404_2@android@H_404_2@:text=@H_404_2@"@string/textViewA"
@H_404_2@        @H_404_2@android@H_404_2@:textSize=@H_404_2@"24dp"
@H_404_2@        @H_404_2@android@H_404_2@:gravity=@H_404_2@"center_horizontal"
@H_404_2@        @H_404_2@android@H_404_2@:textColor=@H_404_2@"@android:color/holo_blue_light"@H_404_2@/>
@H_404_2@
@H_404_2@    <LinearLayout
@H_404_2@        @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@        @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@        @H_404_2@android@H_404_2@:orientation=@H_404_2@"horizontal"
@H_404_2@        @H_404_2@android@H_404_2@:layout_marginRight=@H_404_2@"20dp"
@H_404_2@        @H_404_2@android@H_404_2@:layout_marginTop=@H_404_2@"10dp"@H_404_2@>
@H_404_2@
@H_404_2@        <TextView
@H_404_2@            @H_404_2@android@H_404_2@:layout_width=@H_404_2@"80dp"
@H_404_2@            @H_404_2@android@H_404_2@:gravity=@H_404_2@"center_vertical"
@H_404_2@            @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@            @H_404_2@android@H_404_2@:text=@H_404_2@"@string/textView1"
@H_404_2@            @H_404_2@android@H_404_2@:textSize=@H_404_2@"18dp"
@H_404_2@            @H_404_2@android@H_404_2@:textColor=@H_404_2@"@android:color/holo_blue_light"@H_404_2@/>
@H_404_2@
@H_404_2@        <EditText
@H_404_2@            @H_404_2@android@H_404_2@:id=@H_404_2@"@+id/editTextA1"
@H_404_2@            @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@            @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@            @H_404_2@android@H_404_2@:inputType=@H_404_2@"text"
@H_404_2@            @H_404_2@android@H_404_2@:textSize=@H_404_2@"18dp"
@H_404_2@
@H_404_2@            @H_404_2@android@H_404_2@:background=@H_404_2@"@drawable/editbg"@H_404_2@/>
@H_404_2@    </LinearLayout>
@H_404_2@
@H_404_2@    <LinearLayout
@H_404_2@        @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@        @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@        @H_404_2@android@H_404_2@:orientation=@H_404_2@"horizontal"
@H_404_2@        @H_404_2@android@H_404_2@:layout_marginTop=@H_404_2@"10dp"
@H_404_2@        @H_404_2@android@H_404_2@:layout_marginRight=@H_404_2@"20dp"@H_404_2@>
@H_404_2@
@H_404_2@        <TextView
@H_404_2@            @H_404_2@android@H_404_2@:layout_width=@H_404_2@"80dp"
@H_404_2@            @H_404_2@android@H_404_2@:gravity=@H_404_2@"center_vertical"
@H_404_2@            @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@            @H_404_2@android@H_404_2@:text=@H_404_2@"@string/textView2"
@H_404_2@            @H_404_2@android@H_404_2@:textSize=@H_404_2@"18dp"
@H_404_2@            @H_404_2@android@H_404_2@:textColor=@H_404_2@"@android:color/holo_blue_light"@H_404_2@/>
@H_404_2@
@H_404_2@        <EditText
@H_404_2@            @H_404_2@android@H_404_2@:id=@H_404_2@"@+id/editTextA2"
@H_404_2@            @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@            @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@            @H_404_2@android@H_404_2@:inputType=@H_404_2@"textPassword"
@H_404_2@            @H_404_2@android@H_404_2@:textSize=@H_404_2@"18dp"
@H_404_2@            @H_404_2@android@H_404_2@:background=@H_404_2@"@drawable/editbg"@H_404_2@/>
@H_404_2@</LinearLayout>
@H_404_2@    <Button
@H_404_2@        @H_404_2@android@H_404_2@:id=@H_404_2@"@+id/buttonA1"
@H_404_2@        @H_404_2@android@H_404_2@:layout_width=@H_404_2@"wrap_content"
@H_404_2@        @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@        @H_404_2@android@H_404_2@:text=@H_404_2@"@string/button1"
@H_404_2@        @H_404_2@android@H_404_2@:textSize=@H_404_2@"18sp"
@H_404_2@        @H_404_2@android@H_404_2@:textColor=@H_404_2@"@color/chuise2"
@H_404_2@        @H_404_2@android@H_404_2@:layout_gravity=@H_404_2@"center_horizontal"
@H_404_2@        @H_404_2@android@H_404_2@:layout_marginTop=@H_404_2@"10dp"
@H_404_2@        @H_404_2@android@H_404_2@:background=@H_404_2@"@drawable/buttonbg"@H_404_2@/>
@H_404_2@</LinearLayout>
@H_404_2@
@H_404_2@<!--2个图片按钮 -->
@H_404_2@<LinearLayout
@H_404_2@    @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@    @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@    @H_404_2@android@H_404_2@:orientation=@H_404_2@"horizontal"
@H_404_2@    @H_404_2@android@H_404_2@:layout_marginTop=@H_404_2@"30dp"@H_404_2@>
@H_404_2@    <ImageButton
@H_404_2@        @H_404_2@android@H_404_2@:onClick=@H_404_2@"Login"
@H_404_2@        @H_404_2@android@H_404_2@:layout_width=@H_404_2@"0dp"
@H_404_2@        @H_404_2@android@H_404_2@:layout_weight=@H_404_2@"1"
@H_404_2@        @H_404_2@android@H_404_2@:layout_height=@H_404_2@"100dp"
@H_404_2@        @H_404_2@android@H_404_2@:scaleType=@H_404_2@"fitXY"
@H_404_2@        @H_404_2@android@H_404_2@:src=@H_404_2@"@drawable/a2"
@H_404_2@        @H_404_2@android@H_404_2@:background=@H_404_2@"#00000000"@H_404_2@/>
@H_404_2@    <ImageButton
@H_404_2@        @H_404_2@android@H_404_2@:onClick=@H_404_2@"Look"
@H_404_2@        @H_404_2@android@H_404_2@:layout_width=@H_404_2@"0dp"
@H_404_2@        @H_404_2@android@H_404_2@:layout_weight=@H_404_2@"1"
@H_404_2@        @H_404_2@android@H_404_2@:layout_height=@H_404_2@"100dp"
@H_404_2@        @H_404_2@android@H_404_2@:scaleType=@H_404_2@"fitXY"
@H_404_2@        @H_404_2@android@H_404_2@:src=@H_404_2@"@drawable/a3"
@H_404_2@        @H_404_2@android@H_404_2@:background=@H_404_2@"#00000000"
@H_404_2@        @H_404_2@android@H_404_2@:layout_marginLeft=@H_404_2@"30dp"@H_404_2@/>
@H_404_2@</LinearLayout>
@H_404_2@</LinearLayout>
@H_404_2@
@H_404_2@</ScrollView>
@H_404_2@

2、LoginActivity.java@H_404_2@

注册方法:这里写了很多if else的判断,可能有点看晕,但是修改密码AlterActivity 更加晕呢@H_404_2@

或许我应该有接口封装一来,有人跟我说:写成接口,然后用true,false这么判断,@H_404_2@

可是也有人对我说:你这里的代码复用性不高,写成接口封装会造成负担.....@H_404_2@

所以,我还没有封装呢....@H_404_2@


package @H_404_2@example.com.user_sqlite;
@H_404_2@
@H_404_2@import @H_404_2@android.content.Intent;
@H_404_2@import @H_404_2@android.support.v7.app.AppCompatActivity;
@H_404_2@import @H_404_2@android.os.Bundle;
@H_404_2@import @H_404_2@android.view.View;
@H_404_2@import @H_404_2@android.widget.Button;
@H_404_2@import @H_404_2@android.widget.EditText;
@H_404_2@import @H_404_2@android.widget.Toast;
@H_404_2@
@H_404_2@import @H_404_2@example.com.user_sqlite.dao.UserDao;
@H_404_2@
@H_404_2@public class @H_404_2@LoginActivity extends @H_404_2@AppCompatActivity {

    // 用户注册
@H_404_2@    @H_404_2@private @H_404_2@EditText editTextB1@H_404_2@;
@H_404_2@    private @H_404_2@EditText editTextB2@H_404_2@;
@H_404_2@    private @H_404_2@EditText editTextB3@H_404_2@;
@H_404_2@    private @H_404_2@Button buttonB1@H_404_2@;
@H_404_2@
@H_404_2@    @H_404_2@// 数据库操作类
@H_404_2@    @H_404_2@private @H_404_2@UserDao userDao@H_404_2@;
@H_404_2@
@H_404_2@    @H_404_2@@Override
@H_404_2@    @H_404_2@protected void @H_404_2@onCreate@H_404_2@(Bundle savedInstanceState) {
        super@H_404_2@.onCreate(savedInstanceState);
@H_404_2@        @H_404_2@setContentView(R.layout.activity_login@H_404_2@);
@H_404_2@
@H_404_2@        @H_404_2@userDao @H_404_2@= new @H_404_2@UserDao(this@H_404_2@);
@H_404_2@        @H_404_2@editTextB1 @H_404_2@= (EditText) findViewById(R.id.editTextB1@H_404_2@);
@H_404_2@        @H_404_2@editTextB2 @H_404_2@= (EditText) findViewById(R.id.editTextB2@H_404_2@);
@H_404_2@        @H_404_2@editTextB3 @H_404_2@= (EditText) findViewById(R.id.editTextB3@H_404_2@);
@H_404_2@
@H_404_2@        @H_404_2@buttonB1 @H_404_2@= (Button) findViewById(R.id.buttonB1@H_404_2@);
@H_404_2@        @H_404_2@//用户注册
@H_404_2@        @H_404_2@buttonB1@H_404_2@.setOnClickListener(new @H_404_2@View.OnClickListener() {
            @Override
@H_404_2@            @H_404_2@public void @H_404_2@onClick@H_404_2@(View v) {
                String uname = editTextB1@H_404_2@.getText() + ""@H_404_2@;
@H_404_2@                @H_404_2@String upwd = editTextB2@H_404_2@.getText() + ""@H_404_2@;
@H_404_2@                if @H_404_2@(uname.equals(null@H_404_2@) || uname == "" @H_404_2@|| upwd.equals(null@H_404_2@) || upwd == ""@H_404_2@){
                    Toast.makeText@H_404_2@(LoginActivity.this,@H_404_2@Toast.LENGTH_SHORT@H_404_2@).show();
@H_404_2@                @H_404_2@}else @H_404_2@{
                    String confirmPwd = editTextB3@H_404_2@.getText()+ ""@H_404_2@;
@H_404_2@                if @H_404_2@(!upwd.equals(confirmPwd)){
                    Toast.makeText@H_404_2@(LoginActivity.this,@H_404_2@"两次输入密码不一致"@H_404_2@,@H_404_2@Toast.LENGTH_SHORT@H_404_2@).show();
@H_404_2@                @H_404_2@}else @H_404_2@{
                if @H_404_2@(userDao@H_404_2@.dbQueryOneByUsername(uname) == null@H_404_2@){
                    userDao@H_404_2@.dbInsert(uname,@H_404_2@upwd);
@H_404_2@                    @H_404_2@Toast.makeText@H_404_2@(LoginActivity.this,@H_404_2@"注册成功!用户名:"@H_404_2@+uname+
                            ",密码:"@H_404_2@+upwd+",请牢记!"@H_404_2@,@H_404_2@Toast.LENGTH_SHORT@H_404_2@).show();
@H_404_2@                    @H_404_2@finish();
@H_404_2@                    @H_404_2@Intent intent = new @H_404_2@Intent(LoginActivity.this,@H_404_2@MainActivity.class@H_404_2@);
@H_404_2@                    @H_404_2@startActivity(intent);
@H_404_2@                    @H_404_2@}else @H_404_2@{
                        Toast.makeText@H_404_2@(LoginActivity.this,@H_404_2@"该用户已被注册"@H_404_2@,@H_404_2@Toast.LENGTH_SHORT@H_404_2@).show();
@H_404_2@                    @H_404_2@}
                    }
                }
            }
        });
@H_404_2@
@H_404_2@    @H_404_2@}
}

2.1、activity_login:注册页面@H_404_2@


<?@H_404_2@xml version=@H_404_2@"1.0" @H_404_2@encoding=@H_404_2@"utf-8"@H_404_2@?>
@H_404_2@<LinearLayout @H_404_2@xmlns:@H_404_2@android@H_404_2@=@H_404_2@"http://schemas.android.com/apk/res/android"
@H_404_2@    @H_404_2@xmlns:@H_404_2@tools@H_404_2@=@H_404_2@"http://schemas.android.com/tools"
@H_404_2@    @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@    @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@    @H_404_2@android@H_404_2@:orientation=@H_404_2@"vertical"
@H_404_2@    @H_404_2@android@H_404_2@:padding=@H_404_2@"10dp"
@H_404_2@    @H_404_2@tools@H_404_2@:context=@H_404_2@"example.com.user_sqlite.LoginActivity"@H_404_2@>
@H_404_2@
@H_404_2@    <ImageView
@H_404_2@        @H_404_2@android@H_404_2@:layout_width=@H_404_2@"100dp"
@H_404_2@        @H_404_2@android@H_404_2@:layout_height=@H_404_2@"120dp"
@H_404_2@        @H_404_2@android@H_404_2@:src=@H_404_2@"@drawable/a1"
@H_404_2@        @H_404_2@android@H_404_2@:layout_gravity=@H_404_2@"center_horizontal"@H_404_2@/>
@H_404_2@
@H_404_2@    <LinearLayout
@H_404_2@        @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@        @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@        @H_404_2@android@H_404_2@:orientation=@H_404_2@"vertical"@H_404_2@>
@H_404_2@        <TextView
@H_404_2@            @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@            @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@            @H_404_2@android@H_404_2@:text=@H_404_2@"@string/textViewB"
@H_404_2@            @H_404_2@android@H_404_2@:@H_404_2@textSize@H_404_2@=@H_404_2@"24sp"
@H_404_2@            @H_404_2@android@H_404_2@:gravity=@H_404_2@"center_horizontal"
@H_404_2@            @H_404_2@android@H_404_2@:layout_marginTop=@H_404_2@"20dp"@H_404_2@/>
@H_404_2@
@H_404_2@        <LinearLayout
@H_404_2@            @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@            @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@            @H_404_2@android@H_404_2@:orientation=@H_404_2@"horizontal" @H_404_2@>
@H_404_2@
@H_404_2@            <TextView
@H_404_2@                @H_404_2@android@H_404_2@:layout_width=@H_404_2@"80dp"
@H_404_2@                @H_404_2@android@H_404_2@:gravity=@H_404_2@"center_vertical"
@H_404_2@                @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@                @H_404_2@android@H_404_2@:text=@H_404_2@"@string/textView1"
@H_404_2@                @H_404_2@android@H_404_2@:@H_404_2@textSize@H_404_2@=@H_404_2@"18sp" @H_404_2@/>
@H_404_2@
@H_404_2@            <EditText
@H_404_2@                @H_404_2@android@H_404_2@:id=@H_404_2@"@+id/editTextB1"
@H_404_2@                @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@                @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@                @H_404_2@android@H_404_2@:inputType=@H_404_2@"text"
@H_404_2@                @H_404_2@android@H_404_2@:@H_404_2@textSize@H_404_2@=@H_404_2@"18sp" @H_404_2@/>
@H_404_2@        </LinearLayout>
@H_404_2@
@H_404_2@        <LinearLayout
@H_404_2@            @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@            @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@            @H_404_2@android@H_404_2@:orientation=@H_404_2@"horizontal" @H_404_2@>
@H_404_2@
@H_404_2@            <TextView
@H_404_2@                @H_404_2@android@H_404_2@:layout_width=@H_404_2@"80dp"
@H_404_2@                @H_404_2@android@H_404_2@:gravity=@H_404_2@"center_vertical"
@H_404_2@                @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@                @H_404_2@android@H_404_2@:text=@H_404_2@"@string/textView2"
@H_404_2@                @H_404_2@android@H_404_2@:@H_404_2@textSize@H_404_2@=@H_404_2@"18sp" @H_404_2@/>
@H_404_2@
@H_404_2@            <EditText
@H_404_2@                @H_404_2@android@H_404_2@:id=@H_404_2@"@+id/editTextB2"
@H_404_2@                @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@                @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@                @H_404_2@android@H_404_2@:inputType=@H_404_2@"textPassword"
@H_404_2@                @H_404_2@android@H_404_2@:@H_404_2@textSize@H_404_2@=@H_404_2@"18sp" @H_404_2@/>
@H_404_2@        </LinearLayout>
@H_404_2@
@H_404_2@        <LinearLayout
@H_404_2@            @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@            @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@            @H_404_2@android@H_404_2@:orientation=@H_404_2@"horizontal" @H_404_2@>
@H_404_2@
@H_404_2@            <TextView
@H_404_2@                @H_404_2@android@H_404_2@:layout_width=@H_404_2@"wrap_content"
@H_404_2@                @H_404_2@android@H_404_2@:gravity=@H_404_2@"center_vertical"
@H_404_2@                @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@                @H_404_2@android@H_404_2@:text=@H_404_2@"@string/textView3"
@H_404_2@                @H_404_2@android@H_404_2@:@H_404_2@textSize@H_404_2@=@H_404_2@"18sp" @H_404_2@/>
@H_404_2@
@H_404_2@            <EditText
@H_404_2@                @H_404_2@android@H_404_2@:id=@H_404_2@"@+id/editTextB3"
@H_404_2@                @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@                @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@                @H_404_2@android@H_404_2@:inputType=@H_404_2@"textPassword"
@H_404_2@                @H_404_2@android@H_404_2@:@H_404_2@textSize@H_404_2@=@H_404_2@"18sp" @H_404_2@/>
@H_404_2@        </LinearLayout>
@H_404_2@
@H_404_2@        <Button
@H_404_2@            @H_404_2@android@H_404_2@:id=@H_404_2@"@+id/buttonB1"
@H_404_2@            @H_404_2@android@H_404_2@:layout_width=@H_404_2@"wrap_content"
@H_404_2@            @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@            @H_404_2@android@H_404_2@:text=@H_404_2@"@string/button1"
@H_404_2@            @H_404_2@android@H_404_2@:@H_404_2@textSize@H_404_2@=@H_404_2@"18sp"
@H_404_2@            @H_404_2@android@H_404_2@:textColor=@H_404_2@"@color/chuise"
@H_404_2@            @H_404_2@android@H_404_2@:layout_gravity=@H_404_2@"center_horizontal"@H_404_2@/>
@H_404_2@    </LinearLayout>
@H_404_2@
@H_404_2@</LinearLayout>
@H_404_2@

3、AlterActivity.java :修改密码@H_404_2@

这里的if_else判断更多@H_404_2@

package @H_404_2@example.com.user_sqlite;
@H_404_2@
@H_404_2@import @H_404_2@android.content.Intent;
@H_404_2@import @H_404_2@android.support.v7.app.AppCompatActivity;
@H_404_2@import @H_404_2@android.os.Bundle;
@H_404_2@import @H_404_2@android.view.View;
@H_404_2@import @H_404_2@android.widget.Button;
@H_404_2@import @H_404_2@android.widget.EditText;
@H_404_2@import @H_404_2@android.widget.Toast;
@H_404_2@
@H_404_2@import @H_404_2@example.com.user_sqlite.dao.UserDao;
@H_404_2@import @H_404_2@example.com.user_sqlite.entity.User;
@H_404_2@
@H_404_2@public class @H_404_2@AlterActivity extends @H_404_2@AppCompatActivity {
    // 修改密码
@H_404_2@    @H_404_2@private @H_404_2@EditText editTextC1@H_404_2@;
@H_404_2@    private @H_404_2@EditText editTextC2@H_404_2@;
@H_404_2@    private @H_404_2@EditText editTextC3@H_404_2@;
@H_404_2@    private @H_404_2@EditText editTextC4@H_404_2@;
@H_404_2@    private @H_404_2@Button buttonC1@H_404_2@;
@H_404_2@
@H_404_2@    @H_404_2@// 数据库操作类
@H_404_2@    @H_404_2@private @H_404_2@UserDao userDao@H_404_2@;
@H_404_2@    @H_404_2@@Override
@H_404_2@    @H_404_2@protected void @H_404_2@onCreate@H_404_2@(Bundle savedInstanceState) {
        super@H_404_2@.onCreate(savedInstanceState);
@H_404_2@        @H_404_2@setContentView(R.layout.activity_alter@H_404_2@);
@H_404_2@
@H_404_2@        @H_404_2@userDao @H_404_2@= new @H_404_2@UserDao(this@H_404_2@);
@H_404_2@        @H_404_2@editTextC1 @H_404_2@= (EditText) findViewById(R.id.editTextC1@H_404_2@);
@H_404_2@        @H_404_2@editTextC2 @H_404_2@= (EditText) findViewById(R.id.editTextC2@H_404_2@);
@H_404_2@        @H_404_2@editTextC3 @H_404_2@= (EditText) findViewById(R.id.editTextC3@H_404_2@);
@H_404_2@        @H_404_2@editTextC4 @H_404_2@= (EditText) findViewById(R.id.editTextC4@H_404_2@);
@H_404_2@
@H_404_2@        @H_404_2@buttonC1 @H_404_2@= (Button) findViewById(R.id.buttonC1@H_404_2@);
@H_404_2@
@H_404_2@        @H_404_2@//修改密码
@H_404_2@        @H_404_2@buttonC1@H_404_2@.setOnClickListener(new @H_404_2@View.OnClickListener() {
            @Override
@H_404_2@            @H_404_2@public void @H_404_2@onClick@H_404_2@(View v) {
                String uname=editTextC1@H_404_2@.getText() + ""@H_404_2@;
@H_404_2@                @H_404_2@String upwd =editTextC2@H_404_2@.getText() + ""@H_404_2@;
@H_404_2@
@H_404_2@            if @H_404_2@(uname.equals(null@H_404_2@) || uname == "" @H_404_2@|| upwd.equals(null@H_404_2@) || upwd == ""@H_404_2@){
                Toast.makeText@H_404_2@(AlterActivity.this,@H_404_2@Toast.LENGTH_SHORT@H_404_2@).show();
@H_404_2@            @H_404_2@}else @H_404_2@{
                User user = userDao@H_404_2@.dbQueryOneByUsername(uname);
@H_404_2@                if @H_404_2@(userDao@H_404_2@.dbQueryOneByUsername(uname) == null@H_404_2@) {
                    Toast.makeText@H_404_2@(AlterActivity.this,@H_404_2@Toast.LENGTH_SHORT@H_404_2@).show();
@H_404_2@                @H_404_2@}else @H_404_2@{
                    if @H_404_2@(!user.getUpwd().equals(upwd)) {
                        Toast.makeText@H_404_2@(AlterActivity.this,@H_404_2@Toast.LENGTH_SHORT@H_404_2@).show();
@H_404_2@                    @H_404_2@} else @H_404_2@{
                        String newPwd = editTextC3@H_404_2@.getText() + ""@H_404_2@;
@H_404_2@                        @H_404_2@String confirmNewPwd = editTextC4@H_404_2@.getText() + ""@H_404_2@;
@H_404_2@
@H_404_2@                        if @H_404_2@(newPwd.equals(null@H_404_2@) || newPwd == ""@H_404_2@) {
                            Toast.makeText@H_404_2@(AlterActivity.this,@H_404_2@"新密码不能为空!"@H_404_2@,@H_404_2@Toast.LENGTH_SHORT@H_404_2@).show();
@H_404_2@                        @H_404_2@} else @H_404_2@{
                            if @H_404_2@(!newPwd.equals(confirmNewPwd)) {
                                Toast.makeText@H_404_2@(AlterActivity.this,@H_404_2@"两次密码输入不一致!"@H_404_2@,@H_404_2@Toast.LENGTH_SHORT@H_404_2@).show();
@H_404_2@                            @H_404_2@} else @H_404_2@{
                                userDao@H_404_2@.dbUpdatePassword(uname,@H_404_2@newPwd);
@H_404_2@                                @H_404_2@Toast.makeText@H_404_2@(AlterActivity.this,@H_404_2@"修改密码成功!新密码:" @H_404_2@+ newPwd + ",请牢记"@H_404_2@,@H_404_2@Toast.LENGTH_SHORT@H_404_2@).show();
@H_404_2@                                @H_404_2@finish();
@H_404_2@                                @H_404_2@Intent intent= new @H_404_2@Intent(AlterActivity.this,@H_404_2@MainActivity.class@H_404_2@);
@H_404_2@                                @H_404_2@startActivity(intent);
@H_404_2@                            @H_404_2@}
                        }
                    }
                }
                }
            }
        });
@H_404_2@
@H_404_2@    @H_404_2@}
}

3.1、activity_alter.xml@H_404_2@

修改密码页面:@H_404_2@

<?@H_404_2@xml version=@H_404_2@"1.0" @H_404_2@encoding=@H_404_2@"utf-8"@H_404_2@?>
@H_404_2@<LinearLayout @H_404_2@xmlns:@H_404_2@android@H_404_2@=@H_404_2@"http://schemas.android.com/apk/res/android"
@H_404_2@    @H_404_2@xmlns:@H_404_2@tools@H_404_2@=@H_404_2@"http://schemas.android.com/tools"
@H_404_2@    @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@    @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@    @H_404_2@android@H_404_2@:orientation=@H_404_2@"vertical"
@H_404_2@    @H_404_2@android@H_404_2@:padding=@H_404_2@"10dp"
@H_404_2@    @H_404_2@tools@H_404_2@:context=@H_404_2@"example.com.user_sqlite.AlterActivity"@H_404_2@>
@H_404_2@
@H_404_2@    <LinearLayout
@H_404_2@        @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@        @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@        @H_404_2@android@H_404_2@:orientation=@H_404_2@"vertical"@H_404_2@>
@H_404_2@        <TextView
@H_404_2@            @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@            @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@            @H_404_2@android@H_404_2@:text=@H_404_2@"@string/textViewC"
@H_404_2@            @H_404_2@android@H_404_2@:textSize=@H_404_2@"24sp"
@H_404_2@            @H_404_2@android@H_404_2@:textColor=@H_404_2@"@android:color/holo_blue_light"@H_404_2@/>
@H_404_2@
@H_404_2@        <LinearLayout
@H_404_2@            @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@            @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@            @H_404_2@android@H_404_2@:orientation=@H_404_2@"horizontal" @H_404_2@>
@H_404_2@
@H_404_2@            <TextView
@H_404_2@                @H_404_2@android@H_404_2@:layout_width=@H_404_2@"80dp"
@H_404_2@                @H_404_2@android@H_404_2@:gravity=@H_404_2@"center_vertical"
@H_404_2@                @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@                @H_404_2@android@H_404_2@:text=@H_404_2@"@string/textView1"
@H_404_2@                @H_404_2@android@H_404_2@:textSize=@H_404_2@"18sp" @H_404_2@/>
@H_404_2@
@H_404_2@            <EditText
@H_404_2@                @H_404_2@android@H_404_2@:id=@H_404_2@"@+id/editTextC1"
@H_404_2@                @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@                @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@                @H_404_2@android@H_404_2@:inputType=@H_404_2@"text"
@H_404_2@                @H_404_2@android@H_404_2@:textSize=@H_404_2@"18sp" @H_404_2@/>
@H_404_2@        </LinearLayout>
@H_404_2@
@H_404_2@        <LinearLayout
@H_404_2@            @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@            @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@            @H_404_2@android@H_404_2@:orientation=@H_404_2@"horizontal" @H_404_2@>
@H_404_2@
@H_404_2@            <TextView
@H_404_2@                @H_404_2@android@H_404_2@:layout_width=@H_404_2@"80dp"
@H_404_2@                @H_404_2@android@H_404_2@:gravity=@H_404_2@"center_vertical"
@H_404_2@                @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@                @H_404_2@android@H_404_2@:text=@H_404_2@"@string/textView4"
@H_404_2@                @H_404_2@android@H_404_2@:textSize=@H_404_2@"18sp" @H_404_2@/>
@H_404_2@
@H_404_2@            <EditText
@H_404_2@                @H_404_2@android@H_404_2@:id=@H_404_2@"@+id/editTextC2"
@H_404_2@                @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@                @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@                @H_404_2@android@H_404_2@:inputType=@H_404_2@"textPassword"
@H_404_2@                @H_404_2@android@H_404_2@:textSize=@H_404_2@"18sp" @H_404_2@/>
@H_404_2@        </LinearLayout>
@H_404_2@
@H_404_2@        <LinearLayout
@H_404_2@            @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@            @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@            @H_404_2@android@H_404_2@:orientation=@H_404_2@"horizontal" @H_404_2@>
@H_404_2@
@H_404_2@            <TextView
@H_404_2@                @H_404_2@android@H_404_2@:layout_width=@H_404_2@"80dp"
@H_404_2@                @H_404_2@android@H_404_2@:gravity=@H_404_2@"center_vertical"
@H_404_2@                @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@                @H_404_2@android@H_404_2@:text=@H_404_2@"@string/textView5"
@H_404_2@                @H_404_2@android@H_404_2@:textSize=@H_404_2@"18sp" @H_404_2@/>
@H_404_2@
@H_404_2@            <EditText
@H_404_2@                @H_404_2@android@H_404_2@:id=@H_404_2@"@+id/editTextC3"
@H_404_2@                @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@                @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@                @H_404_2@android@H_404_2@:inputType=@H_404_2@"textPassword"
@H_404_2@                @H_404_2@android@H_404_2@:textSize=@H_404_2@"18sp" @H_404_2@/>
@H_404_2@        </LinearLayout>
@H_404_2@
@H_404_2@        <LinearLayout
@H_404_2@            @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@            @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@            @H_404_2@android@H_404_2@:orientation=@H_404_2@"horizontal" @H_404_2@>
@H_404_2@
@H_404_2@            <TextView
@H_404_2@                @H_404_2@android@H_404_2@:layout_width=@H_404_2@"wrap_content"
@H_404_2@                @H_404_2@android@H_404_2@:gravity=@H_404_2@"center_vertical"
@H_404_2@                @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@                @H_404_2@android@H_404_2@:text=@H_404_2@"@string/textView3"
@H_404_2@                @H_404_2@android@H_404_2@:textSize=@H_404_2@"18sp" @H_404_2@/>
@H_404_2@
@H_404_2@            <EditText
@H_404_2@                @H_404_2@android@H_404_2@:id=@H_404_2@"@+id/editTextC4"
@H_404_2@                @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@                @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@                @H_404_2@android@H_404_2@:inputType=@H_404_2@"textPassword"
@H_404_2@                @H_404_2@android@H_404_2@:textSize=@H_404_2@"18sp" @H_404_2@/>
@H_404_2@        </LinearLayout>
@H_404_2@
@H_404_2@        <Button
@H_404_2@            @H_404_2@android@H_404_2@:id=@H_404_2@"@+id/buttonC1"
@H_404_2@            @H_404_2@android@H_404_2@:layout_width=@H_404_2@"wrap_content"
@H_404_2@            @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@            @H_404_2@android@H_404_2@:text=@H_404_2@"@string/button1"
@H_404_2@            @H_404_2@android@H_404_2@:textSize=@H_404_2@"18sp"
@H_404_2@            @H_404_2@android@H_404_2@:textColor=@H_404_2@"@color/chuise"
@H_404_2@            @H_404_2@android@H_404_2@:layout_gravity=@H_404_2@"center_horizontal"
@H_404_2@            @H_404_2@android@H_404_2@:background=@H_404_2@"@drawable/buttonbg"
@H_404_2@            @H_404_2@android@H_404_2@:layout_marginTop=@H_404_2@"10dp"@H_404_2@/>
@H_404_2@    </LinearLayout>
@H_404_2@
@H_404_2@</LinearLayout>
@H_404_2@

4、TableActivity.java@H_404_2@

代码布局,输出显示注册用户@H_404_2@


package @H_404_2@example.com.user_sqlite;
@H_404_2@
@H_404_2@import @H_404_2@android.app.Activity;
@H_404_2@import @H_404_2@android.content.Intent;
@H_404_2@import @H_404_2@android.os.Bundle;
@H_404_2@import @H_404_2@android.view.KeyEvent;
@H_404_2@import @H_404_2@android.view.View;
@H_404_2@import @H_404_2@android.view.ViewGroup;
@H_404_2@import @H_404_2@android.widget.Button;
@H_404_2@import @H_404_2@android.widget.LinearLayout;
@H_404_2@import @H_404_2@android.widget.TableLayout;
@H_404_2@import @H_404_2@android.widget.TableRow;
@H_404_2@import @H_404_2@android.widget.TextView;
@H_404_2@import @H_404_2@android.widget.Toast;
@H_404_2@
@H_404_2@import @H_404_2@org.w3c.dom.Text;
@H_404_2@
@H_404_2@import @H_404_2@java.util.ArrayList;
@H_404_2@
@H_404_2@import @H_404_2@example.com.user_sqlite.dao.UserDao;
@H_404_2@import @H_404_2@example.com.user_sqlite.entity.User;
@H_404_2@
@H_404_2@public class @H_404_2@TableActivity extends @H_404_2@Activity {
//数据库操作类
@H_404_2@    @H_404_2@private @H_404_2@UserDao userDao@H_404_2@;
@H_404_2@    private @H_404_2@LinearLayout linearLayout1@H_404_2@;
@H_404_2@
@H_404_2@    @H_404_2@@Override
@H_404_2@    @H_404_2@protected void @H_404_2@onCreate@H_404_2@(Bundle savedInstanceState) {
        super@H_404_2@.onCreate(savedInstanceState);
@H_404_2@        @H_404_2@setContentView(R.layout.activity_table@H_404_2@);
@H_404_2@
@H_404_2@//代码布局,输出注册用户信息
@H_404_2@        @H_404_2@userDao @H_404_2@= new @H_404_2@UserDao(this@H_404_2@);
@H_404_2@        @H_404_2@linearLayout1 @H_404_2@= (LinearLayout) findViewById(R.id.linearLayout1@H_404_2@);
@H_404_2@
@H_404_2@        int @H_404_2@userSize = userDao@H_404_2@.dbGetUserSize();
@H_404_2@        @H_404_2@TextView textView1 = new @H_404_2@TextView(this@H_404_2@);
@H_404_2@        @H_404_2@textView1.setText("共有"@H_404_2@+userSize+ "个用户"@H_404_2@);
@H_404_2@        @H_404_2@textView1.setTextSize(24@H_404_2@);
@H_404_2@        @H_404_2@linearLayout1@H_404_2@.addView(textView1,@H_404_2@1@H_404_2@);
@H_404_2@
@H_404_2@        if @H_404_2@(userSize>0@H_404_2@){
            ArrayList<User> userList = userDao@H_404_2@.dbQueryAll();
@H_404_2@            @H_404_2@TableLayout tableLayout1 = new @H_404_2@TableLayout(this@H_404_2@);
@H_404_2@            @H_404_2@tableLayout1.setStretchAllColumns(true@H_404_2@);
@H_404_2@            @H_404_2@TableRow tableRow = new @H_404_2@TableRow(this@H_404_2@);
@H_404_2@            @H_404_2@TextView textView = new @H_404_2@TextView(this@H_404_2@);
@H_404_2@            @H_404_2@textView.setTextSize(24@H_404_2@);
@H_404_2@            @H_404_2@textView.setText("用户名"@H_404_2@);
@H_404_2@            @H_404_2@tableRow.addView(textView);
@H_404_2@
@H_404_2@            @H_404_2@textView= new @H_404_2@TextView(this@H_404_2@);
@H_404_2@            @H_404_2@textView.setTextSize(24@H_404_2@);
@H_404_2@            @H_404_2@textView.setText("密码"@H_404_2@);
@H_404_2@            @H_404_2@tableRow.addView(textView);
@H_404_2@
@H_404_2@            @H_404_2@textView = new @H_404_2@TextView(this@H_404_2@);
@H_404_2@            @H_404_2@textView.setTextSize(24@H_404_2@);
@H_404_2@            @H_404_2@textView.setText("操作"@H_404_2@);
@H_404_2@            @H_404_2@tableRow.addView(textView);
@H_404_2@
@H_404_2@//新建的TableRow添加到TableLayout
@H_404_2@            @H_404_2@tableLayout1.addView(tableRow,new @H_404_2@TableLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT@H_404_2@,@H_404_2@                    @H_404_2@ViewGroup.LayoutParams.MATCH_PARENT@H_404_2@));
@H_404_2@            for @H_404_2@(int @H_404_2@i=0@H_404_2@;@H_404_2@i<userSize;@H_404_2@i++){
                User user = userList.get(i);
@H_404_2@//一个用户占据一行
@H_404_2@                @H_404_2@tableRow = new @H_404_2@TableRow(this@H_404_2@);
@H_404_2@                @H_404_2@textView = new @H_404_2@TextView(this@H_404_2@);
@H_404_2@                @H_404_2@textView.setTextSize(18@H_404_2@);
@H_404_2@                @H_404_2@textView.setText(user.getUname());
@H_404_2@                @H_404_2@tableRow.addView(textView);
@H_404_2@
@H_404_2@                @H_404_2@textView = new @H_404_2@TextView(this@H_404_2@);
@H_404_2@                @H_404_2@textView.setTextSize(18@H_404_2@);
@H_404_2@                @H_404_2@textView.setText(user.getUpwd());
@H_404_2@                @H_404_2@tableRow.addView(textView);
@H_404_2@
@H_404_2@                @H_404_2@Button button = new @H_404_2@Button(this@H_404_2@);
@H_404_2@                @H_404_2@button.setText("删除"@H_404_2@);
@H_404_2@                @H_404_2@button.setTextSize(18@H_404_2@);
@H_404_2@                @H_404_2@button.setId(user.getId());
@H_404_2@                @H_404_2@button.setOnClickListener(new @H_404_2@View.OnClickListener() {
                @Override
@H_404_2@                @H_404_2@public void @H_404_2@onClick@H_404_2@(View v) {
                    userDao@H_404_2@.dbDeleteUser(v.getId());
@H_404_2@                    @H_404_2@finish();
@H_404_2@                    @H_404_2@Intent intent = new @H_404_2@Intent(TableActivity.this,@H_404_2@TableActivity.class@H_404_2@);
@H_404_2@                    @H_404_2@startActivity(intent);
@H_404_2@                    @H_404_2@Toast.makeText@H_404_2@(TableActivity.this,@H_404_2@"删除成功!"@H_404_2@,@H_404_2@Toast.LENGTH_SHORT@H_404_2@).show();
@H_404_2@                @H_404_2@}
            });
@H_404_2@                @H_404_2@tableRow.addView(button);
@H_404_2@//新建的TableRow添加到TableLayout
@H_404_2@                @H_404_2@tableLayout1.addView(tableRow,new @H_404_2@TableLayout.LayoutParams(
                        ViewGroup.LayoutParams.WRAP_CONTENT@H_404_2@,@H_404_2@                        @H_404_2@ViewGroup.LayoutParams.MATCH_PARENT@H_404_2@));
@H_404_2@            @H_404_2@}
            linearLayout1@H_404_2@.addView(tableLayout1,@H_404_2@2@H_404_2@);
@H_404_2@        @H_404_2@}

    }
//对物理按钮的监听
@H_404_2@    @H_404_2@public boolean @H_404_2@onKeyDown@H_404_2@(int @H_404_2@keycode,@H_404_2@KeyEvent event){
        switch @H_404_2@(keycode){
            case @H_404_2@KeyEvent.KEYCODE_BACK@H_404_2@:
                finish(); @H_404_2@//关闭这个Activity
@H_404_2@                @H_404_2@Intent intent = new @H_404_2@Intent(TableActivity.this,@H_404_2@MainActivity.class@H_404_2@);
@H_404_2@                @H_404_2@startActivity(intent);
@H_404_2@                break;
@H_404_2@        @H_404_2@}
                return super@H_404_2@.onKeyDown(keycode,@H_404_2@event);
@H_404_2@    @H_404_2@}
//登录跳转
@H_404_2@    @H_404_2@public void @H_404_2@dengLu@H_404_2@(View v){
        finish();
@H_404_2@        @H_404_2@Intent intent = new @H_404_2@Intent(this,@H_404_2@MainActivity.class@H_404_2@);
@H_404_2@        @H_404_2@startActivity(intent);
@H_404_2@    @H_404_2@}

//注册跳转
@H_404_2@    @H_404_2@public void @H_404_2@Login@H_404_2@(View v){
        finish();
@H_404_2@        @H_404_2@Intent intent = new @H_404_2@Intent(this,@H_404_2@LoginActivity.class@H_404_2@);
@H_404_2@        @H_404_2@startActivity(intent);
@H_404_2@    @H_404_2@}
    //修改跳转
@H_404_2@    @H_404_2@public void @H_404_2@Alter@H_404_2@(View v){
        finish();
@H_404_2@        @H_404_2@Intent intent = new @H_404_2@Intent(this,@H_404_2@AlterActivity.class@H_404_2@);
@H_404_2@        @H_404_2@startActivity(intent);
@H_404_2@    @H_404_2@}
}

4.1、activity_table:xml@H_404_2@

输出信息页面,因为是代码布局的,所以有点丑....@H_404_2@


<?@H_404_2@xml version=@H_404_2@"1.0" @H_404_2@encoding=@H_404_2@"utf-8"@H_404_2@?>
@H_404_2@<ScrollView @H_404_2@xmlns:@H_404_2@android@H_404_2@=@H_404_2@"http://schemas.android.com/apk/res/android"
@H_404_2@    @H_404_2@xmlns:@H_404_2@tools@H_404_2@=@H_404_2@"http://schemas.android.com/tools"
@H_404_2@    @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@    @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@    @H_404_2@android@H_404_2@:padding=@H_404_2@"10dp"
@H_404_2@    @H_404_2@android@H_404_2@:orientation=@H_404_2@"vertical"@H_404_2@>
@H_404_2@<LinearLayout
@H_404_2@    @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@    @H_404_2@android@H_404_2@:layout_height=@H_404_2@"match_parent"
@H_404_2@    @H_404_2@android@H_404_2@:orientation=@H_404_2@"vertical"@H_404_2@>
@H_404_2@<!-- 注册用户显示 -->
@H_404_2@    @H_404_2@<LinearLayout
@H_404_2@        @H_404_2@android@H_404_2@:id=@H_404_2@"@+id/linearLayout1"
@H_404_2@        @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@        @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@        @H_404_2@android@H_404_2@:orientation=@H_404_2@"vertical" @H_404_2@>
@H_404_2@
@H_404_2@        <View
@H_404_2@            @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@            @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@            @H_404_2@android@H_404_2@:tag=@H_404_2@"1" @H_404_2@/>
@H_404_2@
@H_404_2@        <View
@H_404_2@            @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@            @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@            @H_404_2@android@H_404_2@:tag=@H_404_2@"2" @H_404_2@/>
@H_404_2@
@H_404_2@    </LinearLayout>
@H_404_2@
@H_404_2@ @H_404_2@<!-- 三个按钮 -->
@H_404_2@    @H_404_2@<LinearLayout
@H_404_2@        @H_404_2@android@H_404_2@:layout_width=@H_404_2@"match_parent"
@H_404_2@        @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@        @H_404_2@android@H_404_2@:orientation=@H_404_2@"horizontal"@H_404_2@>
@H_404_2@
@H_404_2@        <Button
@H_404_2@            @H_404_2@android@H_404_2@:layout_width=@H_404_2@"0dp"
@H_404_2@            @H_404_2@android@H_404_2@:layout_weight=@H_404_2@"1"
@H_404_2@            @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@            @H_404_2@android@H_404_2@:text=@H_404_2@"@string/textViewA"
@H_404_2@            @H_404_2@android@H_404_2@:textColor=@H_404_2@"@color/chuise"
@H_404_2@            @H_404_2@android@H_404_2@:background=@H_404_2@"@drawable/buttonbg"
@H_404_2@            @H_404_2@android@H_404_2@:onClick=@H_404_2@"dengLu" @H_404_2@/>
@H_404_2@
@H_404_2@        <Button
@H_404_2@            @H_404_2@android@H_404_2@:layout_width=@H_404_2@"0dp"
@H_404_2@            @H_404_2@android@H_404_2@:layout_weight=@H_404_2@"1"
@H_404_2@            @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@            @H_404_2@android@H_404_2@:text=@H_404_2@"@string/textViewB"
@H_404_2@            @H_404_2@android@H_404_2@:textColor=@H_404_2@"@color/chuise"
@H_404_2@            @H_404_2@android@H_404_2@:background=@H_404_2@"@drawable/buttonbg"
@H_404_2@            @H_404_2@android@H_404_2@:layout_marginLeft=@H_404_2@"10dp"
@H_404_2@            @H_404_2@android@H_404_2@:onClick=@H_404_2@"Login"@H_404_2@/>
@H_404_2@        <Button
@H_404_2@            @H_404_2@android@H_404_2@:layout_width=@H_404_2@"0dp"
@H_404_2@            @H_404_2@android@H_404_2@:layout_weight=@H_404_2@"1"
@H_404_2@            @H_404_2@android@H_404_2@:layout_height=@H_404_2@"wrap_content"
@H_404_2@            @H_404_2@android@H_404_2@:text=@H_404_2@"@string/textViewC"
@H_404_2@            @H_404_2@android@H_404_2@:textColor=@H_404_2@"@color/chuise"
@H_404_2@            @H_404_2@android@H_404_2@:background=@H_404_2@"@drawable/buttonbg"
@H_404_2@            @H_404_2@android@H_404_2@:layout_marginLeft=@H_404_2@"10dp"
@H_404_2@            @H_404_2@android@H_404_2@:onClick=@H_404_2@"Alter"@H_404_2@/>
@H_404_2@
@H_404_2@    </LinearLayout>
@H_404_2@</LinearLayout>
@H_404_2@</ScrollView>@H_404_2@

@H_404_2@

有时候我会用很多finish(); 大家自行决定要不要加吧.....@H_404_2@


四、drwable资源文件:@H_404_2@

1、buttonbg.xml@H_404_2@

按钮的样式@H_404_2@

<shape @H_404_2@xmlns:@H_404_2@android@H_404_2@=@H_404_2@"http://schemas.android.com/apk/res/android" @H_404_2@>
@H_404_2@    @H_404_2@<!-- 描边 -->
@H_404_2@    @H_404_2@<stroke @H_404_2@android@H_404_2@:width=@H_404_2@"0.5dp"  @H_404_2@android@H_404_2@:color=@H_404_2@"@android:color/holo_blue_light"@H_404_2@/>
@H_404_2@    @H_404_2@<!-- 填充 -->
@H_404_2@    <!--<solid android:color=""/>-->
@H_404_2@
@H_404_2@    <!-- 圆角 -->
@H_404_2@    @H_404_2@<corners @H_404_2@android@H_404_2@:radius=@H_404_2@"2dp"@H_404_2@/>
@H_404_2@
@H_404_2@</shape>@H_404_2@

2、editbg.xml@H_404_2@

输入框的样式:

<shape @H_404_2@xmlns:@H_404_2@android@H_404_2@=@H_404_2@"http://schemas.android.com/apk/res/android" @H_404_2@>
@H_404_2@    @H_404_2@<!-- 描边 -->
@H_404_2@    @H_404_2@<stroke @H_404_2@android@H_404_2@:width=@H_404_2@"0.5dp"  @H_404_2@android@H_404_2@:color=@H_404_2@"@android:color/holo_blue_light"@H_404_2@/>
@H_404_2@    @H_404_2@<!-- 填充 -->
@H_404_2@    <!--<solid android:color=""/>-->
@H_404_2@
@H_404_2@    <!-- 圆角 -->
@H_404_2@    @H_404_2@<corners @H_404_2@android@H_404_2@:radius=@H_404_2@"5dp"@H_404_2@/>
@H_404_2@
@H_404_2@    @H_404_2@<!-- 内容与边框间距 -->
@H_404_2@    @H_404_2@<padding @H_404_2@android@H_404_2@:left=@H_404_2@"10dp" @H_404_2@android@H_404_2@:top=@H_404_2@"5dp"
@H_404_2@        @H_404_2@android@H_404_2@:right=@H_404_2@"0dp" @H_404_2@android@H_404_2@:bottom=@H_404_2@"0dp"@H_404_2@/>
@H_404_2@
@H_404_2@</shape>@H_404_2@

至于图片啊....大家自己找吧:@H_404_2@



五、values属性文件夹@H_404_2@

colors自己写@H_404_2@

strings.xml:@H_404_2@

<resources>
@H_404_2@    <string @H_404_2@name=@H_404_2@"app_name"@H_404_2@>@H_404_2@sqlite数据库的增删改查</string>
@H_404_2@    <string @H_404_2@name=@H_404_2@"action_settings"@H_404_2@>@H_404_2@Settings</string>
@H_404_2@    <string @H_404_2@name=@H_404_2@"textViewA"@H_404_2@>@H_404_2@用户登录</string>
@H_404_2@    <string @H_404_2@name=@H_404_2@"textViewB"@H_404_2@>@H_404_2@用户注册</string>
@H_404_2@    <string @H_404_2@name=@H_404_2@"textViewC"@H_404_2@>@H_404_2@修改密码</string>
@H_404_2@
@H_404_2@    <string @H_404_2@name=@H_404_2@"textView1"@H_404_2@>@H_404_2@用户名</string>
@H_404_2@    <string @H_404_2@name=@H_404_2@"textView2"@H_404_2@>@H_404_2@密  码 :</string>
@H_404_2@    <string @H_404_2@name=@H_404_2@"textView3"@H_404_2@>@H_404_2@确认密码:</string>
@H_404_2@    <string @H_404_2@name=@H_404_2@"textView4"@H_404_2@>@H_404_2@旧密码:</string>
@H_404_2@    <string @H_404_2@name=@H_404_2@"textView5"@H_404_2@>@H_404_2@新密码:</string>
@H_404_2@
@H_404_2@    <string @H_404_2@name=@H_404_2@"button1"@H_404_2@>@H_404_2@确定</string>
@H_404_2@    <string @H_404_2@name=@H_404_2@"button2"@H_404_2@>@H_404_2@查看用户</string>
@H_404_2@    <string @H_404_2@name=@H_404_2@"button3"@H_404_2@>@H_404_2@返回</string>
@H_404_2@
@H_404_2@</resources>@H_404_2@


@H_404_2@

对于这个简单的项目,其实还有个致命的缺陷呢!@H_404_2@

就是非当前用户也可以修改密码,这里大家多做一个判断@H_404_2@吧@H_404_2@

原文链接:https://www.f2er.com/sqlite/198482.html

猜你在找的Sqlite相关文章