• 购物车


    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
    <TextView
        android:id="@+id/tv1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="用户名:"
        android:textSize="30dp"
        android:layout_marginTop="60dp"
        />
    <EditText
        android:id="@+id/et1"
        android:layout_width="600dp"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/tv1"
        android:layout_marginTop="50dp"
        android:textSize="30dp"
        />
    
    <TextView
        android:id="@+id/tv2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="密码:"
        android:textSize="30dp"
        android:layout_marginTop="50dp"
        android:layout_below="@+id/tv1"
        />
    <EditText
        android:id="@+id/et2"
        android:layout_width="600dp"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/tv2"
        android:layout_marginTop="30dp"
        android:textSize="30dp"
        android:layout_below="@+id/et1"
    
        />
    
    
        <Button
            android:layout_marginTop="80dp"
            android:layout_width="300dp"
            android:layout_height="wrap_content"
            android:text="注册"
            android:textSize="50dp"
            android:layout_below="@+id/et2"
            android:layout_centerHorizontal="true"
            android:onClick="click"
            />
    </RelativeLayout>
    package com.example.ccc;
    
    import android.content.ContentValues;
    import android.os.Bundle;
    import android.app.Activity;
    import android.database.sqlite.SQLiteDatabase;
    import android.view.Menu;
    import android.view.View;
    import android.widget.EditText;
     
    public class MainActivity extends Activity {
     
        private String username;
        private String password;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
     
     
     }
        public void click(View view){
            username =((EditText) findViewById(R.id.et1)).getText().toString();
            password =((EditText) findViewById(R.id.et2)).getText().toString();
            StuOpenHelper helper = new StuOpenHelper(this);
            SQLiteDatabase db =helper.getReadableDatabase();
            ContentValues cv = new ContentValues();
            cv.put("username",username);
            cv.put("password",password);
            db.insert("stu",null,cv);
            db.close();
        }
    }
  • 相关阅读:
    HTML DOM教程 9HTML DOM Window 对象
    HTML DOM教程 11HTML DOM Screen 对象
    Android项目中把bin文件夹里面的.apk文件删除,怎么让它再生成
    Qt把ping www.baidu.com之后的内容的内容输出到一个名为output的文档
    Qt之QProcess 和 c语言对比
    Git的Windows版本Msysgit的中文乱码解决
    多系统 grub之ubuntu的 grub
    QT中调用外部程序:QProcess的使用
    repo的小结
    恢复Ubuntu默认的面板
  • 原文地址:https://www.cnblogs.com/qsf1975747------/p/13983755.html
Copyright © 2020-2023  润新知