当前位置:   article > 正文

新手报到android studio简单的密码记事本,实现增删改查功能_android studio修改密码功能实现

android studio修改密码功能实现
项目的结构如下图:

DBHlper是创建数据库的java文件,RegisterActivity是用户注册的逻辑代码,MainActivity是用户登入代码,MemoInfo是bean文件,Memo是登入成功后的逻辑代码,SaveMemo是用户记录的逻辑代码,showmemo是用户修改记事本该条内容的逻辑代码。下面开始看源码吧!!!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

数据库的创建:创建了tb_user、tb_memo两个数据库,它们之间通过userid关联。这样每个用户之间记录的东西就不会弄混了。(A记录的东西不会出现在B用户的页面上)

登入:

package com.example.jsjx.memo;

import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    private EditText edt_username;
    private EditText edt_password;
    private Button btn_login;
    private Button btn_register;
    String name;
    String  password;
    String  id;
    private DBHelper dbHelper;
    SQLiteDatabase db;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.index);
        init();
        dbHelper=new DBHelper(this);
        btn_register.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(MainActivity.this,RegisterActivity.class);
                startActivity(intent);

            }
        });
        btn_login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                db=dbHelper.getReadableDatabase();
                name = edt_username.getText().toString();
                password = edt_password.getText().toString();
                if(enter(name,password)){
                    Toast.makeText(MainActivity.this, "登入成功", Toast.LENGTH_SHORT).show();
                    String sql="select user_id from tb_user where username=? and password=?";
                    Cursor cursor = db.rawQuery(sql, new String[] {name, password});
                    while(cursor.moveToNext()){
                        id=Integer.toString(cursor.getInt(0));
                        System.out.println(id);

                    }
                    cursor.close();
//                    SharedPreferences.Editor editor=sp.edit();
//                    editor.putString("name",name);
//                    editor.putString("password",password);
//                    editor.commit();

                    new Thread(){
                        public  void run(){
                            super.run();
                            try {
                                Thread.sleep(3000);
                                Intent intent1=new Intent(MainActivity.this,Memo.class);
                                intent1.putExtra("name",name);
                                intent1.putExtra("id",id);
                                startActivity(intent1);
                            }catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                        }
                    }.start();
                }
                else if((TextUtils.isEmpty(name)||TextUtils.isEmpty(password))||(TextUtils.isEmpty(name)&&TextUtils.isEmpty(password))){
                    Toast.makeText(MainActivity.this, "请输入用户名或密码", Toast.LENGTH_SHORT).show();

                }
                else{
                    Toast.makeText(MainActivity.this, "登入失败", Toast.LENGTH_SHORT).show();

                }
                db.close();


            }

        });
    }
    public void init(){
        edt_username=(EditText)findViewById(R.id.edt_username);
        edt_password=(EditText)findViewById(R.id.edt_password);
        btn_login=(Button)findViewById(R.id.btn_login);
        btn_register=(Button)findViewById(R.id.btn_go_register);
    }
    public boolean enter(String name,String password) {
        SQLiteDatabase db = dbHelper.getWritableDatabase();
        String sql = "select user_id from tb_user where username=? and password=?";
        Cursor cursor = db.rawQuery(sql, new String[] {name, password});
        if (cursor.getCount()!=0) {
            cursor.close();
            return true;
        }
        return false;
    }
}

注册:

package com.example.jsjx.memo;

import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class RegisterActivity extends AppCompatActivity{
    private EditText edt_setname;
    private EditText edt_setpassword;
    private EditText edt_confirm_password;
    private Button btn_register;
    String name;
    String id;
    String password;
    private DBHelper dbHelper;
    ContentValues contentValues=new ContentValues();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.register);
        init();
        dbHelper=new DBHelper(this);
        btn_register.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SQLiteDatabase db;
                db=dbHelper.getWritableDatabase();
                name=edt_setname.getText().toString();
                password=edt_setpassword.getText().toString();
                if (edt_setname.getText().toString().contains(" ") || edt_setpassword.getText().toString().contains(" ")) {
                    System.out.println(name+"\n"+password);
                    Toast.makeText(RegisterActivity.this, "输入的用户名或密码不能包含空格", Toast.LENGTH_SHORT).show();
                    return;

                }
                else if(edt_setpassword.getText().toString().length()==0||edt_setname.getText().toString().length()==0){
                    Toast.makeText(RegisterActivity.this, "请输入用户名或密码", Toast.LENGTH_SHORT).show();
                    return;

                }
                else if(!edt_confirm_password.getText().toString().equals(edt_setpassword.getText().toString())){
                    Toast.makeText(RegisterActivity.this, "两次密码不一致,请确认再注册", Toast.LENGTH_SHORT).show();
                    return;
                }
                name = edt_setname.getText().toString();
                password = edt_setpassword.getText().toString();
                if(login(name)){
                    System.out.println(name+"\n"+password);
                    Toast.makeText(RegisterActivity.this, "该用户名已注册", Toast.LENGTH_SHORT).show();
                    return;
                }

                contentValues.put("username", name);
                contentValues.put("password", password);
                db.insert("tb_user", null, contentValues);
                String sql="select user_id from tb_user where username=? and password=?";
                Cursor cursor = db.rawQuery(sql, new String[] {name, password});
                while(cursor.moveToNext()){
                    id=Integer.toString(cursor.getInt(0));
                    System.out.println(id);
                }
                cursor.close();
                db.close();
                Toast.makeText(RegisterActivity.this, "注册成功", Toast.LENGTH_SHORT).show();
                new Thread(){
                    @Override
                    public void run() {
                        super.run();
                        try {
                            Thread.sleep(2000);
                            Intent intent = new Intent(RegisterActivity.this,Memo.class);
                            intent.putExtra("name",name);
                            intent.putExtra("id",id);
                            startActivity(intent);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }.start();
            }
        });
    }
    public void init(){
        edt_setname=(EditText)findViewById(R.id.edt_setusername);
        edt_setpassword=(EditText)findViewById(R.id.edt_setpassword);
        edt_confirm_password=(EditText)findViewById(R.id.edt_confirm_password);
        btn_register=(Button)findViewById(R.id.btn_register);
    }
    public boolean login(String name) {
        SQLiteDatabase db = dbHelper.getWritableDatabase();
        String sql = "select * from tb_user where username=?";
        Cursor cursor = db.rawQuery(sql, new String[] {name});
        if (cursor.getCount()!=0) {
            cursor.close();
            return true;
        }
        return false;
    }
}

listview显示用户记录的信息:

package com.example.jsjx.memo;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;
import java.util.ArrayList;
public class Memo extends AppCompatActivity {
    private TextView welcome;
    private ImageButton btn_add;
    private ListView listView;
    private DBHelper dbHelper;
    private ArrayList<Memo_info> MemoList;
    SQLiteDatabase db;
    private int id;
    private String name;
    private String strid;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btn_add=(ImageButton)findViewById(R.id.btn_add);
        listView=(ListView)findViewById(R.id.lv_memoList);
        dbHelper=new DBHelper(this);
        db=dbHelper.getReadableDatabase();
        welcome=(TextView)findViewById(R.id.welcome_word);
        final Intent intent=getIntent();
        MemoList=new ArrayList<>();
        id=Integer.parseInt(intent.getStringExtra("id"));
        String sql_name="select username from tb_user where user_id=?";
        Cursor c=db.rawQuery(sql_name,new String[]{Integer.toString(id)});
        while(c.moveToNext()){
            name=c.getString(c.getColumnIndex("username"));
        }
        strid=Integer.toString(id);
        welcome.setText(name+"欢迎你!");
        String sql="select * from tb_memo where userID=?";
        Cursor cursor = db.rawQuery(sql,new String[]{Integer.toString(id)});
        while(cursor.moveToNext()){
            if(id==cursor.getInt(2)){
                String title=cursor.getString(cursor.getColumnIndex("title"));
                String createDate=cursor.getString(cursor.getColumnIndex("createDate"));
                int id=cursor.getInt(0);
                Memo_info memo=new Memo_info(title,createDate,id);
                System.out.println("title:"+title+"createDate:"+createDate+"id:"+id);
                MemoList.add(memo);
            }
        }
        listView.setAdapter(new BaseAdapter() {
            @Override
            public int getCount() {
                return MemoList.size();
            }

            @Override
            public Object getItem(int i) {
                return i;
            }

            @Override
            public long getItemId(int i) {
                return i;
            }

            @Override
            public View getView(int i, View convertView, ViewGroup viewGroup) {
                View view;
                if (convertView==null){
                    view = View.inflate(getBaseContext(),R.layout.list_item_memo,null);
                }else{
                    view = convertView;
                }
                Memo_info memo=MemoList.get(i);
                TextView title=(TextView)view.findViewById(R.id.title);
                TextView content=(TextView)view.findViewById(R.id.content);
                TextView getsqlId=(TextView)view.findViewById(R.id.getsqlId);
                TextView createDate=(TextView)view.findViewById(R.id.noticeDate);
                title.setText(memo.getTitle());
                content.setText(memo.getContent());
                createDate.setText(memo.getCreateDate());
                getsqlId.setText(Integer.toString(memo.getId()));
                return view;
            }
        });
        btn_add.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent1=new Intent(Memo.this,SaveMemo.class);
                intent1.putExtra("userID",strid);
                startActivity(intent1);
            }
        });
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                TextView view1=(TextView)view.findViewById(R.id.getsqlId);
                String memoid=view1.getText().toString();
                Intent intent2=new Intent(Memo.this,showmemo.class);
                intent2.putExtra("memoid",memoid);
                intent2.putExtra("user_id",strid);
                startActivity(intent2);
            }
        });
        listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
                    Button btn_del=(Button)view.findViewById(R.id.btn_del);
                    btn_del.setVisibility(View.VISIBLE);
                    TextView view1=(TextView)view.findViewById(R.id.getsqlId);
                    final String memoid=view1.getText().toString();
                    btn_del.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            db=dbHelper.getWritableDatabase();
                            db.delete("tb_memo","id=?",new String[]{memoid});
                            Intent intent3=new Intent(Memo.this,Memo.class);
                            System.out.println("调用删除方法");
                            intent3.putExtra("id",strid);
                            startActivity(intent3);
                        }
                    });

                return true;
            }

        });

    }
}

增加信息代码:

package com.example.jsjx.memo;
import android.app.AlertDialog;
import android.content.ContentValues;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.widget.EditText;

import java.text.SimpleDateFormat;
import java.util.Date;

public class SaveMemo extends AppCompatActivity {
    private DBHelper dbHelper;
    private EditText et1;
    private String data;
    private String title;
    private String createDate;
    SQLiteDatabase db;
    private int id;
    ContentValues contentValues=new ContentValues();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.edt_memo);
        et1=(EditText) findViewById(R.id.edt1);
        dbHelper=new DBHelper(this);
        Intent intent=getIntent();
        id=Integer.parseInt(intent.getStringExtra("userID"));
        SimpleDateFormat formatter   =   new   SimpleDateFormat   ("yyyy年MM月dd日   HH:mm:ss");
        Date curDate =  new Date(System.currentTimeMillis());
        createDate=formatter.format(curDate);

    }
    public boolean onKeyDown(int keyCode, KeyEvent event)

    {

        if (keyCode == KeyEvent.KEYCODE_BACK )

        {

            // 创建退出对话框

            AlertDialog isExit = new AlertDialog.Builder(this).create();

            // 设置对话框标题

            isExit.setTitle("系统提示");

            // 设置对话框消息

            isExit.setMessage("确定要退出保存吗");

            // 添加选择按钮并注册监听

            isExit.setButton("确定", listener);

            isExit.setButton2("取消", listener);

            // 显示对话框

            isExit.show();

        }

        return false;

    }
    DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener()

    {

        public void onClick(DialogInterface dialog, int which)

        {

            switch (which)

            {

                case AlertDialog.BUTTON_POSITIVE:// "确认"按钮退出程序
                    data=et1.getText().toString();
                    System.out.println("初始data:"+data);
                    if(data.length()==0){
                        System.out.println("无数据data:"+data);
                        System.out.println("时间:"+createDate);
                        Intent intent=new Intent(SaveMemo.this,Memo.class);
                        intent.putExtra("id",Integer.toString(id));
                        startActivity(intent);
                    }else if(data.length()>=10){
                        System.out.println("有数据data:"+data);
                        System.out.println("data:"+data);
                        title=data.substring(0,10);
                        db=dbHelper.getWritableDatabase();
                        contentValues.put("userID",id);
                        contentValues.put("title", title);
                        contentValues.put("createDate",createDate);
                        contentValues.put("content",data);
                        db.insert("tb_memo",null,contentValues);
                        Intent intent=new Intent(SaveMemo.this,Memo.class);
                        intent.putExtra("id",Integer.toString(id));
                        startActivity(intent);
                    }else{
                        System.out.println("有数据data:"+data);
                        System.out.println("data:"+data);
                        title=data;
                        db=dbHelper.getWritableDatabase();
                        contentValues.put("userID",id);
                        contentValues.put("title", title);
                        contentValues.put("createDate",createDate);
                        contentValues.put("content",data);
                        db.insert("tb_memo",null,contentValues);
                        Intent intent=new Intent(SaveMemo.this,Memo.class);
                        intent.putExtra("id",Integer.toString(id));
                        startActivity(intent);
                    }
                    break;

                case AlertDialog.BUTTON_NEGATIVE:// "取消"第二个按钮取消对话框

                    break;

                default:

                    break;
            }

        }

    };

}

修改用户记录的信息:

package com.example.jsjx.memo;

import android.app.AlertDialog;
import android.content.ContentValues;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.widget.EditText;
import java.text.SimpleDateFormat;
import java.util.Date;

public class showmemo extends AppCompatActivity {
    private EditText et2;
    private String id;
    private String userid;
    private DBHelper dbHelper;
    private String memo_info;
    private String data;
    private String title;
    private String createDate;
    SQLiteDatabase db;
    ContentValues contentValues=new ContentValues();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.showmemo);
        et2=(EditText) findViewById(R.id.edt2);
        Intent intent=getIntent();
        dbHelper=new DBHelper(this);
        db=dbHelper.getReadableDatabase();
        id=intent.getStringExtra("memoid");
        userid=intent.getStringExtra("user_id");
        System.out.println("id:"+id);
        SimpleDateFormat formatter   =   new   SimpleDateFormat   ("yyyy年MM月dd日   HH:mm:ss");
        Date curDate =  new Date(System.currentTimeMillis());
        createDate=formatter.format(curDate);
        String sql="select content from tb_memo where id=?";
        Cursor cursor=db.rawQuery(sql,new String[]{id});
        while(cursor.moveToNext()){
            memo_info=cursor.getString(cursor.getColumnIndex("content"));
        }
        et2.setText(memo_info);
        db.close();
    }
    public boolean onKeyDown(int keyCode, KeyEvent event)

    {

        if (keyCode == android.view.KeyEvent.KEYCODE_BACK )

        {

            // 创建退出对话框

            AlertDialog isExit = new AlertDialog.Builder(this).create();

            // 设置对话框标题

            isExit.setTitle("系统提示");

            // 设置对话框消息

            isExit.setMessage("确定要退出保存吗");

            // 添加选择按钮并注册监听

            isExit.setButton("确定", listener);

            isExit.setButton2("取消", listener);

            // 显示对话框

            isExit.show();

        }

        return false;

    }
    DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener()

    {

        public void onClick(DialogInterface dialog, int which)

        {

            switch (which)

            {

                case AlertDialog.BUTTON_POSITIVE:// "确认"按钮退出程序
                    data=et2.getText().toString();
                    System.out.println("初始data:"+data);
                    if(data.length()<10&&data.length()>0){
                        System.out.println("data长度1:"+data.length());
                        title=data;
                        db=dbHelper.getWritableDatabase();
                        contentValues.put("title", title);
                        contentValues.put("createDate",createDate);
                        contentValues.put("content",data);
                        System.out.println("有数据data:"+data);
                        System.out.println("data:"+data);
                        System.out.println("userid:"+userid);
                        System.out.println("title:"+title);
                        db.update("tb_memo",contentValues,"id=?",new String[]{id});
                        Intent intent=new Intent(showmemo.this,Memo.class);
                        intent.putExtra("id",userid);
                        startActivity(intent);
                    }else if(data.length()>=10){
                        System.out.println("data长度2:"+data.length());
                        System.out.println("有数据data:"+data);
                        System.out.println("data:"+data);
                        System.out.println("userid:"+userid);
                        title=data.substring(0,10);
                        db=dbHelper.getWritableDatabase();
                        contentValues.put("title", title);
                        contentValues.put("createDate",createDate);
                        contentValues.put("content",data);
                        db.update("tb_memo",contentValues,"id=?",new String[]{id});
                        Intent intent=new Intent(showmemo.this,Memo.class);
                        intent.putExtra("id",userid);
                        startActivity(intent);
                    }
                    else{
                        System.out.println("data长度3:"+data.length());
                        System.out.println("无数据data:"+data);
                        System.out.println("时间:"+createDate);
                        System.out.println("userid:"+userid);
                        Intent intent=new Intent(showmemo.this,Memo.class);
                        intent.putExtra("id",userid);
                        startActivity(intent);
                }
                    db.close();
                    break;

                case AlertDialog.BUTTON_NEGATIVE:// "取消"第二个按钮取消对话框

                    break;

                default:

                    break;
            }

        }

    };
}
bean文件:
package com.example.jsjx.memo;

/**
 * Created by liaof on 2018/6/11.
 */

public class Memo_info {
    private String title;
    private String content;
    private String createDate;
    private Integer id;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getCreateDate() {
        return createDate;
    }

    public void setCreateDate(String createDate) {
        this.createDate = createDate;
    }

    public Memo_info(String title, String createDate,int id) {
        this.title = title;
        this.createDate = createDate;
        this.id=id;
    }
}

下面是所有页面布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/index_bg">
    <TextView
        android:id="@+id/index_title"
        android:text="速 记"
        android:textSize="26dp"
        android:textStyle="bold"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="150dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <LinearLayout
        android:id="@+id/line_user"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_below="@id/index_title">
        <TextView
            android:id="@+id/username"
            android:text="昵 称"
            android:layout_marginLeft="5dp"
            android:textSize="24sp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <EditText
            android:id="@+id/edt_username"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/white"
            android:layout_marginLeft="5dp"
            android:inputType="text"
            android:hint="请输入昵称"
            android:padding="5dp"/>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/line_password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_below="@id/line_user">
        <TextView
            android:id="@+id/password"
            android:text="密 码"
            android:layout_marginLeft="5dp"
            android:textSize="24sp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <EditText
            android:id="@+id/edt_password"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/white"
            android:layout_marginLeft="5dp"
            android:inputType="textPassword"
            android:hint="请输入密码"
            android:padding="5dp"/>
    </LinearLayout>
    <Button
        android:id="@+id/btn_login"
        android:layout_below="@+id/line_password"
        android:layout_width="80dp"
        android:layout_marginTop="30dp"
        android:layout_marginLeft="60dp"
        android:background="@android:color/white"
        android:text="登 录"
        android:textSize="16sp"
        android:layout_height="30dp" />
    <Button
        android:id="@+id/btn_go_register"
        android:layout_below="@+id/line_password"
        android:layout_toRightOf="@+id/btn_login"
        android:layout_width="80dp"
        android:layout_marginTop="30dp"
        android:layout_marginLeft="100dp"
        android:background="@android:color/white"
        android:text="注 册"
        android:textSize="16sp"
        android:layout_height="30dp" />
</RelativeLayout>

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.example.jsjx.memo.MainActivity">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >
        <TextView
            android:id="@+id/welcome_word"
            android:textSize="20sp"
            android:textColor="@android:color/holo_blue_bright"
            android:layout_width="wrap_content"
            android:layout_marginTop="10dp"
            android:layout_marginLeft="5dp"
            android:layout_height="wrap_content" />
        <ImageButton
            android:layout_width="40dp"
            android:id="@+id/btn_add"
            android:src="@drawable/add"
            android:layout_height="40dp"
            android:layout_alignParentRight="true"
            android:layout_marginRight="5dp"
             />
    </RelativeLayout>
    <ListView
        android:id="@+id/lv_memoList"
        android:layout_width="match_parent"
        android:layout_height="match_parent"></ListView>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
        <TextView
            android:id="@+id/title"
            android:text="标题"
            android:layout_marginTop="10dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="26sp"/>
        <TextView
            android:id="@+id/noticeDate"
            android:textSize="10sp"
            android:layout_alignParentRight="true"
            android:layout_marginRight="5dp"
            android:text="dafa"
            android:layout_marginBottom="5dp"
            android:layout_alignParentBottom="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    <TextView
        android:id="@+id/content"
        android:layout_centerVertical="true"
        android:text="法师法师法"
        android:layout_marginLeft="20dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <TextView
        android:id="@+id/getsqlId"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:visibility="gone"
        />
    <Button
        android:id="@+id/btn_del"
        android:layout_width="60dp"
        android:layout_height="40dp"
        android:layout_alignParentRight="true"
        android:text="删除"
        android:visibility="gone"
        android:textColor="@android:color/white"
        android:background="@android:color/holo_red_dark"
        android:textSize="16sp"
        android:layout_marginTop="5dp"/>
</RelativeLayout>

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/index_bg">
    <TextView
        android:id="@+id/index_title"
        android:text="注 册"
        android:textSize="26dp"
        android:textStyle="bold"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="150dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <LinearLayout
        android:id="@+id/line_user"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_below="@id/index_title">
        <TextView
            android:id="@+id/username"
            android:text="昵        称"
            android:layout_marginLeft="5dp"
            android:textSize="24sp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <EditText
            android:id="@+id/edt_setusername"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/white"
            android:layout_marginLeft="5dp"
            android:inputType="text"
            android:hint="请输入昵称"
            android:padding="5dp"/>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/line_password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_below="@id/line_user">
        <TextView
            android:id="@+id/password"
            android:text="密        码"
            android:layout_marginLeft="5dp"
            android:textSize="24sp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <EditText
            android:id="@+id/edt_setpassword"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/white"
            android:layout_marginLeft="5dp"
            android:inputType="textPassword"
            android:hint="请输入密码"
            android:padding="5dp"/>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/line_confirm_pwd"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_below="@id/line_password">
        <TextView
            android:id="@+id/confirm_pwd"
            android:text="确认密码"
            android:layout_marginLeft="5dp"
            android:textSize="24sp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <EditText
            android:id="@+id/edt_confirm_password"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/white"
            android:layout_marginLeft="5dp"
            android:inputType="textPassword"
            android:hint="请输入密码"
            android:padding="5dp"/>
    </LinearLayout>
    <Button
        android:id="@+id/btn_register"
        android:layout_below="@+id/line_confirm_pwd"
        android:layout_width="match_parent"
        android:layout_marginTop="30dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:background="@android:color/white"
        android:text="确定注册"
        android:textSize="16sp"
        android:layout_height="30dp" />
</RelativeLayout>

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <EditText
        android:id="@+id/edt1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="top"
        android:inputType="textMultiLine" />
</LinearLayout>

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <EditText
        android:id="@+id/edt2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="top"
        android:inputType="textMultiLine" />
</LinearLayout>

效果图:

用户:lisi密码:123

登入成功到成功页面:

新添信息:

多增加几条:

修改:第一条信息修改为0000000000

删除第一条:长按显示删除按钮

点击后效果:


我这个软件有待改进,但时间原因只能到这里了。祝大家好运,找到一份好工作!!加油


本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号